Example #1
0
    /// <summary>
    /// Gets the internal class ID of the specified type.
    /// </summary>

    static public int GetClassID(System.Type type)
    {
        GameObject       go       = EditorUtility.CreateGameObjectWithHideFlags("Temp", HideFlags.HideAndDontSave);
        Component        uiSprite = go.AddComponent(type);
        SerializedObject ob       = new SerializedObject(uiSprite);
        int classID = ob.FindProperty("m_Script").objectReferenceInstanceIDValue;

        WeaponXITools.DestroyImmediate(go);
        return(classID);
    }
Example #2
0
    /// <summary>
    /// Starts the tweening operation.
    /// </summary>

    static public T Begin <T>(GameObject go, float duration) where T : UITweener
    {
        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 " + WeaponXITools.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);
    }