示例#1
0
 public static string TransformAnimationWrapMode(WrapMode mode)
 {
     if (mAnimationWrapModeTransform.ContainsKey(mode.ToString()))
     {
         return(mAnimationWrapModeTransform[mode.ToString()]);
     }
     return(mode.ToString());
 }
    private WrapMode ConvertWrapMode(string wrapmode)
    {
        IEnumerator enumerator = Enum.GetValues(typeof(WrapMode)).GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                WrapMode wrapMode = (WrapMode)((int)enumerator.Current);
                if (wrapmode == wrapMode.ToString())
                {
                    return(wrapMode);
                }
            }
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
        return(WrapMode.Default);
    }
示例#3
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics  grfx      = e.Graphics;
            Rectangle rectColor = new Rectangle(e.Bounds.Left, e.Bounds.Top, 2 * e.Bounds.Height, e.Bounds.Height);

            rectColor.Inflate(-1, -1);

            Rectangle rectText = new Rectangle(e.Bounds.Left + 2 * e.Bounds.Height,
                                               e.Bounds.Top,
                                               e.Bounds.Width - 2 * e.Bounds.Height,
                                               e.Bounds.Height);

            if (this.Enabled)
            {
                e.DrawBackground();
            }

            WrapMode item = e.Index >= 0 ? (WrapMode)Items[e.Index] : WrapMode.Clamp;

            Rectangle rectShape = new Rectangle(rectColor.X + rectColor.Width / 4, rectColor.Y + rectColor.Height / 4, rectColor.Width / 2, rectColor.Height / 2);

            using (LinearGradientBrush br = new LinearGradientBrush(rectShape, e.ForeColor, e.BackColor, LinearGradientMode.BackwardDiagonal))
            {
                if (item != WrapMode.Clamp)
                {
                    br.WrapMode = item;
                }
                grfx.FillRectangle(br, rectColor);
            }

            using (SolidBrush foreColorBrush = new SolidBrush(e.ForeColor))
            {
                grfx.DrawString(item.ToString(), Font, foreColorBrush, rectText);
            }
        }
示例#4
0
    public override XmlElement ToXml(XmlNode parent, Dictionary <string, string> attributes = null)
    {
        if (attributes == null)
        {
            attributes = new Dictionary <string, string>();
        }
        attributes.Add("animationClip", animationClip);
        attributes.Add("length", length.ToString());
        attributes.Add("mode", mode.ToString());


        return(base.ToXml(parent, attributes));
    }
示例#5
0
    protected void DrawClipDetial()
    {
        if (selectClip == null)
        {
            return;
        }
        var clip = selectClip;

        GUILayout.BeginHorizontal();

        GUI.backgroundColor = m_IsPreviewStyle ? Color.red : Color.green;
        if (GUILayout.Button(m_IsPreviewStyle ? "关闭预览编辑" : "打开预览编辑", GUILayout.Height(30)))
        {
            ChangePreviewDetialStyle();
        }
        GUI.backgroundColor = Color.white;

        GUILayout.EndHorizontal();


        if (EditorTools.DrawHeader("轨道属性", false, false))
        {
            EditorTools.BeginContents(false);
            GUI.skin.label.alignment = TextAnchor.MiddleLeft;
            GUI.contentColor         = Color.white;
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.Label("节点名:", GUILayout.Width(50));
            string node_name = EditorGUILayout.TextField(clip.name, GUILayout.MinWidth(30));
            GUILayout.EndHorizontal();

            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.Label("动作名:", GUILayout.Width(50));
            string clipName = EditorGUILayout.TextField(clip.GetParam("clipName"), GUILayout.MinWidth(30));
            GUILayout.EndHorizontal();

            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.Label("默认长度");
            float length = EditorGUILayout.FloatField(clip.GetParamFloat("length"));
            GUILayout.EndHorizontal();

            GUILayout.Space(5);
            GUILayout.Label("播放速度:");
            float speed = EditorGUILayout.Slider("", clip.GetParamFloat("speed"), 0.0f, 5.0f);

            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.Label("播放模式");
            WrapMode wrapMode = (WrapMode)System.Enum.Parse(typeof(WrapMode), clip.GetParam("wrapMode", WrapMode.Once.ToString()));
            wrapMode = (WrapMode)EditorGUILayout.EnumPopup("", wrapMode, GUILayout.MinWidth(40));
            GUILayout.EndHorizontal();

            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.Label("混合模式");
            var evcrossMode = clip.GetParam("crossMode", AnimatorClip.CrossMode.Direct.ToString());
            AnimatorClip.CrossMode crossMode = (AnimatorClip.CrossMode)System.Enum.Parse(typeof(AnimatorClip.CrossMode), evcrossMode);
            crossMode = (AnimatorClip.CrossMode)EditorGUILayout.EnumPopup("", crossMode, GUILayout.MinWidth(40));
            float fadeFactor = EditorGUILayout.FloatField("", clip.GetParamFloat("fadeFactor"), GUILayout.Width(40));
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            EditorGUILayout.LabelField(EditorActionClipTool.ActionExtraParam.desc);
            GUILayout.BeginHorizontal();
            GUI.backgroundColor = Color.clear;
            string descParam = EditorActionClipTool.ActionExtraParam.descParam;
            GUILayout.TextArea(descParam, GUILayout.Width(60));
            GUI.backgroundColor = Color.white;
            string param = GUILayout.TextArea(clip.GetParam("param"));
            GUILayout.EndHorizontal();

            EditorTools.EndContents();

            if (GUI.changed)
            {
                clip.name          = node_name;
                clip["clipName"]   = clipName;
                clip["speed"]      = speed.ToString();
                clip["length"]     = length.ToString();
                clip["param"]      = param;
                clip["fadeFactor"] = fadeFactor.ToString();
                clip["crossMode"]  = crossMode.ToString();
                clip["wrapMode"]   = wrapMode.ToString();

                this.MarkModified();
            }
        }
    }
示例#6
0
    void SetUpParamTable( )
    {
        AmountToVec();

        paramTbl              = new Hashtable();
        paramTbl["duration"]  = duration.ToString();
        paramTbl["sendDelay"] = delaySecToNextMessage.ToString();
        paramTbl["wrapMode"]  = wrapMode.ToString();
        paramTbl["method"]    = method.ToString();
        switch (animationType)
        {
        case AnimationType.FADE_PANEL:
            paramTbl["fadeTo"] = fadeTo.ToString();
            if (toggleFromAmount)
            {
                paramTbl["fadeFrom"] = fadeFrom.ToString();
            }
            break;

        case AnimationType.MOVE_TO:
            paramTbl["moveX"] = amount.x.ToString();
            paramTbl["moveY"] = amount.y.ToString();
            paramTbl["moveZ"] = amount.z.ToString();
            if (toggleFromAmount)
            {
                paramTbl["fromPosX"] = fromAmount.x.ToString();
                paramTbl["fromPosY"] = fromAmount.y.ToString();
                paramTbl["fromPosZ"] = fromAmount.z.ToString();
            }
            break;

        case AnimationType.ROTATE_TO:
            paramTbl["rotX"] = amount.x.ToString();
            paramTbl["rotY"] = amount.y.ToString();
            paramTbl["rotZ"] = amount.z.ToString();
            if (toggleFromAmount)
            {
                paramTbl["fromRotX"] = fromAmount.x.ToString();
                paramTbl["fromRotY"] = fromAmount.y.ToString();
                paramTbl["fromRotZ"] = fromAmount.z.ToString();
            }
            break;

        case AnimationType.SCALE_TO:
            paramTbl["scaleX"] = amount.x.ToString();
            paramTbl["scaleY"] = amount.y.ToString();
            paramTbl["scaleZ"] = amount.z.ToString();
            if (toggleFromAmount)
            {
                paramTbl["fromScaleX"] = fromAmount.x.ToString();
                paramTbl["fromScaleY"] = fromAmount.y.ToString();
                paramTbl["fromScaleZ"] = fromAmount.z.ToString();
            }
            break;

        case AnimationType.CROSS_FADE:
            if (crossfadeTargetA != null && crossfadeTargetB != null)
            {
                paramTbl["objectA"] = crossfadeTargetA.name;
                paramTbl["objectB"] = crossfadeTargetB.name;
            }
            break;
        }
    }
示例#7
0
 public SerializableWrapMode(WrapMode wrapMode)
 {
     mode = wrapMode.ToString();
 }
    public override string ToString(int codeLanguage, int frameRate)
    {
        string s = "";

        if (!amClip)
        {
            return(null);
        }
        if (codeLanguage == 0)
        {
            // c#
            s += "AMTween.PlayAnimation(obj.gameObject, AMTween.Hash (\"delay\", " + getWaitTime(frameRate, 0f) + "f, \"animation\", \"" + amClip.name + "\", \"wrapmode\", " + "WrapMode." + wrapMode.ToString() + ",\"crossfade\", " + crossfade.ToString().ToLower();
            if (crossfade)
            {
                s += ", \"fadeLength\", " + crossfadeTime.ToString() + "f";
            }
            s += "));";
        }
        else
        {
            // js
            s += "AMTween.PlayAnimation(obj.gameObject, {\"delay\": " + getWaitTime(frameRate, 0f) + ", \"animation\": \"" + amClip.name + "\", \"wrapmode\": " + "WrapMode." + wrapMode.ToString() + ",\"crossfade\": " + crossfade.ToString().ToLower();
            if (crossfade)
            {
                s += ", \"fadeLength\": " + crossfadeTime.ToString();
            }
            s += "});";
        }
        return(s);
    }
示例#9
0
 int wrapModeToIndex(WrapMode wrapMode)
 {
     switch(wrapMode) {
         case WrapMode.Once:
             return 0;
         case WrapMode.Loop:
             return 1;
         case WrapMode.ClampForever:
             return 2;
         case WrapMode.PingPong:
             return 3;
         default:
             Debug.LogError("Animator: No Index found for WrapMode " + wrapMode.ToString());
             return -1;
     }
 }
 public static string TransformAnimationWrapMode( WrapMode mode )
 {
     if( mAnimationWrapModeTransform.ContainsKey( mode.ToString())) {
         return mAnimationWrapModeTransform[ mode.ToString() ];
     }
     return mode.ToString();
 }