static public T Begin <T>(GameObject go, float duration, bool destroyAferTween) where T : UITweener { T comp = go.GetComponent <T>(); #if UNITY_FLASH if ((object)comp == null) { comp = (T)go.AddComponent <T>(); } #else if (comp == null) { comp = go.AddComponent <T>(); } #endif comp.duration = duration; comp.mFactor = 0f; comp.style = Style.Once; comp.enabled = true; comp.mDestroyAfterTween = destroyAferTween; UIWidget[] widgets = comp.GetComponentsInChildren <UIWidget>(true); UIWidget[] selfWidgets = comp.GetComponents <UIWidget>(); comp.chidrenWidgets = NGUITools.CombieArray <UIWidget>(widgets, selfWidgets); return(comp); }
/// <summary> /// Update on start, so there is no frame in-between. /// </summary> void Start() { if (chidrenWidgets == null || chidrenWidgets.Length == 0) { UIWidget[] widgets = GetComponentsInChildren <UIWidget>(true); UIWidget[] selfWidgets = GetComponents <UIWidget>(); chidrenWidgets = NGUITools.CombieArray <UIWidget>(widgets, selfWidgets); } Update(); }