// operation void Initialize() { if (initialized) { return; } if (GetComponent <MeshFilter>() == null) { return; } if (GetComponent <MeshRenderer>() == null) { return; } parentAnimation = (OSC_Animation)this.GetComponentInParent(typeof(OSC_Animation)); if (parentAnimation == null) { return; } meshNumber = transform.GetSiblingIndex(); mesh = new Mesh(); //mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; // 32 bit mesh mesh.MarkDynamic(); GetComponent <MeshFilter>().mesh = mesh; setShader(true); setColor(true); initialized = true; }
public static bool loadCurrentAnimation(string objectName) { if (oscObject == null) { return(false); } // empty if (string.IsNullOrEmpty(objectName)) { foreach (Transform child in oscObject.transform) { child.GetComponent <OSC_Animation>().current = false; child.gameObject.SetActive(false); } currentAnimationObject = null; currentAnimationComponent = null; return(true); } // try saved name if (oscObject.transform.childCount > 0) { Transform testTransform = oscObject.transform.Find(objectName); if (testTransform != null) { foreach (Transform child in oscObject.transform) { if (child.name == objectName) { child.GetComponent <OSC_Animation>().current = true; child.gameObject.SetActive(true); if (child.GetComponent <OSC_Animation>().initialized) { currentAnimationObject = child.gameObject; currentAnimationComponent = child.GetComponent <OSC_Animation>(); } else { loadCurrentAnimation(""); return(false); } continue; } child.GetComponent <OSC_Animation>().current = false; child.gameObject.SetActive(false); } return(true); } } return(false); }