/// <summary> /// Starts the tweening operation. /// </summary> static public T Begin <T> (GameObject go, float duration) where T : BCUITweener { T comp = go.GetComponent <T>(); #if UNITY_FLASH if ((object)comp == null) { comp = (T)go.AddComponent <T>(); } #else // Find the tween with an unset group ID (group ID of 0). if (comp != null && comp.tweenGroup != 0) { comp = null; T[] comps = go.GetComponents <T>(); for (int i = 0, imax = comps.Length; i < imax; ++i) { comp = comps[i]; if (comp != null && comp.tweenGroup == 0) { break; } comp = null; } } if (comp == null) { comp = go.AddComponent <T>(); if (comp == null) { Debug.LogError("Unable to add " + typeof(T) + " to " + BCTools.GetHierarchy(go), go); return(null); } } #endif comp.mStarted = false; comp.duration = duration; comp.mFactor = 0f; comp.mAmountPerDelta = Mathf.Abs(comp.amountPerDelta); comp.style = Style.Once; comp.animationCurve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f)); comp.eventReceiver = null; comp.callWhenFinished = null; comp.enabled = true; return(comp); }