Exemplo n.º 1
0
    /// <summary>
    /// 设置动画包
    /// </summary>
    /// <param name="packName">动画包的名字</param>
    /// <param name="isAuto">是否自动播放</param>
    public TweenPack SetTweenPackSync(string packName, bool isAuto = true)//todo
    {
        enabled = false;
        m_loadingTweens.Clear();
        string tweenPackPath = Config.TweenPacksLoadRoot + "/" + packName;
        var    tweenPack     = Resources.Load <TweenPack>(tweenPackPath);

        m_TweenPack = tweenPack;
        foreach (TweenPack.Attribute attribute in m_TweenPack.Attributes)
        {
            PrePlay(attribute);
        }
        enabled = isAuto;
        return(tweenPack);
    }
Exemplo n.º 2
0
    /// <summary>
    /// 设置动画包
    /// </summary>
    /// <param name="packName">动画包的名字</param>
    /// <param name="isAuto">是否自动播放</param>
    public void SetTweenPack(string packName, bool isAuto = true)//todo
    {
        enabled = false;
        m_loadingTweens.Clear();
        string tweenPackPath = Config.TweenPacksLoadRoot + "/" + packName;

        App.ResourceManager.LoadResource <TweenPack>(tweenPackPath, (TweenPack tweenPack) =>
        {
            if (tweenPack != null)
            {
                m_TweenPack = tweenPack;
                foreach (TweenPack.Attribute attribute in m_TweenPack.Attributes)
                {
                    PrePlay(attribute);
                }
                enabled = isAuto;
            }
        });
    }
Exemplo n.º 3
0
    private void DrawTweenList(UnityEngine.Object[] targets)
    {
        TweenPack tweenPack = targets[0] as TweenPack;

        for (int i = 0; i < tweenPack.Attributes.Count;)
        {
            bool isEqual = true;
            for (int j = 1; j < targets.Length; j++)
            {
                if (!tweenPack.Attributes[i].Equals((targets[j] as TweenPack).Attributes[j]))
                {
                    isEqual = false;
                    break;
                }
            }

            if (isEqual)
            {
                m_attribute.Copy(tweenPack.Attributes[i]);
                string header = m_attribute.TweenName;
                if (LayoutUtility.Foldout(header))
                {
                    LayoutUtility.BeginContents();
                    if (GUILayout.Button("", "ToggleMixed", GUILayout.Width(20f)))
                    {
                        UnityEditor.Undo.RecordObjects(targets, "Remove Tween Attribute");
                        for (int j = 0; j < targets.Length; ++j)
                        {
                            (targets[j] as TweenPack).Attributes.RemoveAt(i);
                            EditorUtility.SetDirty(targets[j]);
                        }
                    }
                    else
                    {
                        DrawTweenAttribute(m_attribute);
                        if (!m_attribute.Equals(tweenPack.Attributes[i]))
                        {
                            UnityEditor.Undo.RecordObjects(targets, "Modify Tween Attribute");
                            for (int j = 0; j < targets.Length; ++j)
                            {
                                (targets[j] as TweenPack).Attributes[i].Copy(m_attribute);
                                EditorUtility.SetDirty(targets[j]);
                            }
                        }
                    }
                    LayoutUtility.EndContents();
                }
            }
            ++i;
        }

        //加入新的Tween
        if (LayoutUtility.Foldout("Add Tween Attribute"))
        {
            LayoutUtility.BeginContents();
            TweenType type = (TweenType)EditorGUILayout.EnumPopup("Tween Type", TweenType.None);
            if (type != TweenType.None)
            {
                UnityEditor.Undo.RecordObjects(targets, "Add Tween Attribute");
                for (int j = 0; j < targets.Length; ++j)
                {
                    TweenPack.Attribute attribute = new TweenPack.Attribute();
                    attribute.TweenType = type;
                    switch (type)
                    {
                    case TweenType.Position:
                        attribute.TweenName = "Position Tween";
                        break;

                    case TweenType.Rotation:
                        attribute.TweenName = "Rotation Tween";
                        break;

                    case TweenType.BlendableScale:
                        attribute.TweenName = "Scale Tween";
                        break;

                    case TweenType.Fade:
                        attribute.TweenName = "Fade Tween";
                        break;

                    case TweenType.Color:
                        attribute.TweenName = "Color Tween";
                        break;

                    case TweenType.UIColor:
                        attribute.TweenName = "UIFade Tween";
                        break;

                    case TweenType.UIFade:
                        attribute.TweenName = "UIFade Tween";
                        break;

                    case TweenType.UIPosition:
                        attribute.TweenName = "UIPosition Tween";
                        break;

                    case TweenType.LocalPosition:
                        attribute.TweenName = "LocalPosition Tween";
                        break;

                    case TweenType.LocalRotation:
                        attribute.TweenName = "LocalRotation Tween";
                        break;

                    case TweenType.LocalScale:
                        attribute.TweenName = "LocalScale Tween";
                        break;

                    case TweenType.UIText:
                        attribute.TweenName = "UIText Tween";
                        break;

                    case TweenType.BlendablePosition:
                        attribute.TweenName = "BlendablePosition Tween";
                        break;
                    }
                    (targets[j] as TweenPack).Attributes.Add(attribute);
                    EditorUtility.SetDirty(targets[j]);
                }
            }
            LayoutUtility.EndContents();
        }
    }