We had to meet Drawcall problem in Mobile game developing using unity 3D.
You should solve it by 2 combination way.

1. Make shard material.
2. Combine mesh.

I writing down about "Combine mesh"

1. Make next script as CombineChild on Unity3D

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]
public class CombineChild : MonoBehaviour
{
void Start()
{
Matrix4x4 thisTransform = transform.worldToLocalMatrix; 
MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>();
CombineInstance[] combine = new CombineInstance[meshFilters.Length];
int i = 0;
while (i < meshFilters.Length)
{
combine[i].mesh = meshFilters[i].sharedMesh;
combine[i].transform = thisTransform * meshFilters[i].transform.localToWorldMatrix;
meshFilters[i].gameObject.SetActive(false);
i++;
}
transform.GetComponent<MeshFilter>().mesh = new Mesh();
transform.GetComponent<MeshFilter>().mesh.CombineMeshes(combine); //, true, true, true);

transform.GetComponent<MeshFilter>().mesh.RecalculateNormals();
transform.gameObject.SetActive(true);
}
}


2. and Please attach to parent gameobject.

Cheers
2017/10/10 02:42 2017/10/10 02:42

first time, Update the code in iTween.cs file

void CallBack(string callbackType){
if (tweenArguments.Contains(callbackType) && !tweenArguments.Contains("ischild")) {
//establish target:
GameObject target;
if (tweenArguments.Contains(callbackType+"target")) {
target=(GameObject)tweenArguments[callbackType+"target"];
}else{
target=gameObject; 
}

/// Start of update
if (tweenArguments[callbackType] is Action<object>)
{
((Action<object>)tweenArguments[callbackType]).Invoke((object)tweenArguments[callbackType + "params"]);
}
else
/// End of update


//throw an error if a string wasn't passed for callback:
if (tweenArguments[callbackType].GetType() == typeof(System.String)) {
target.SendMessage((string)tweenArguments[callbackType],(object)tweenArguments[callbackType+"params"],SendMessageOptions.DontRequireReceiver);
}else{
Debug.LogError("iTween Error: Callback method references must be passed as a String!");
Destroy (this);
}
}
}

Now, You could use the Action<T> delegate in iTween.


iTween.ValueTo(gameObject,
iTween.Hash(
"from", 1f,
"to", 0f,
"time", 1f,
"onupdate", (System.Action<object>)(x => { missedInfo.color = new Color(1f, 0f, 0f, (float)x); }),
"oncomplete", (System.Action<object>)(x => missedInfo.gameObject.SetActive(true))
)
);

 

 

2017/10/06 07:32 2017/10/06 07:32
I am curious why they made UI System complex.
anyway, If you get any event from Event system(on UI), you can choice 2 options.

1. Using EventTrigger 
=> In my thinking, It's so terrible idea.It needs so many manual tasks. So I skip it. 

2. Using EventSystem
=> It's simple. However, I am finding another solution. Because it's not automation by runtime script.

a. add using...
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.EventSystems;


b. inherit from interfaces
public class BehaviorButton : MonoBehaviour, IPointerEnterHandler {

}


c. add Method
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.EventSystems;

public class BehaviorButton : MonoBehaviour, IPointerEnterHandler {
    public void OnPointerEnter(PointerEventData eventData) 
    {
 
    }
}


You can find it on unity's manual. (https://docs.unity3d.com/Manual/SupportedEvents.html)

IPointerEnterHandler - OnPointerEnter - Called when a pointer enters the object
IPointerExitHandler - OnPointerExit - Called when a pointer exits the object

IPointerDownHandler - OnPointerDown - Called when a pointer is pressed on the object
IPointerUpHandler - OnPointerUp - Called when a pointer is released (called on the original the pressed object)

IPointerClickHandler - OnPointerClick - Called when a pointer is pressed and released on the same object

IInitializePotentialDragHandler - OnInitializePotentialDrag - Called when a drag target is found, can be used to initialise values
IBeginDragHandler - OnBeginDrag - Called on the drag object when dragging is about to begin
IDragHandler - OnDrag - Called on the drag object when a drag is happening
IEndDragHandler - OnEndDrag - Called on the drag object when a drag finishes
IDropHandler - OnDrop - Called on the object where a drag finishes

IScrollHandler - OnScroll - Called when a mouse wheel scrolls

IUpdateSelectedHandler - OnUpdateSelected - Called on the selected object each tick

ISelectHandler - OnSelect - Called when the object becomes the selected object
IDeselectHandler - OnDeselect - Called on the selected object becomes deselected

IMoveHandler - OnMove - Called when a move event occurs (left, right, up, down, ect)

ISubmitHandler - OnSubmit - Called when the submit button is pressed
ICancelHandler - OnCancel - Called when the cancel button is pressed

* 영어 울렁증 가지고 계신분들께 죄송 -_-;; 
* 영어 연습겸 블로그에 영어로 작성중입니다.

2017/09/25 08:06 2017/09/25 08:06