Exemplo n.º 1
0
        void InsertAnim(int index, EmojiAnims.Anim current = null)
        {
            var anim = new EmojiAnims.Anim();

            anim.m_Name     = "new emoj";
            anim.m_Duration = current == null ? 0.4f : current.m_Duration;
            anim.m_Frames   = new EmojiAnims.Frame[0];
            EmojiAnims.Anim[] anims;
            if (mTarget.m_Anims != null && mTarget.m_Anims.Length > 0)
            {
                anims = new EmojiAnims.Anim[mTarget.m_Anims.Length + 1];
                index = Mathf.Min(index, anims.Length - 1);
                if (index > 0)
                {
                    System.Array.Copy(mTarget.m_Anims, anims, index);
                }
                if (index < mTarget.m_Anims.Length)
                {
                    System.Array.Copy(mTarget.m_Anims, index, anims, index + 1, mTarget.m_Anims.Length - index);
                }
                anims[index]    = anim;
                mTarget.m_Anims = anims;
                mDirty          = true;
            }
            else
            {
                anims           = new EmojiAnims.Anim[1];
                anims[0]        = anim;
                mTarget.m_Anims = anims;
                mDirty          = true;
            }
        }
        public void Play(string animName)
        {
            if (!IsValid)
            {
                return;
            }
            var anim = m_AnimClips.GetAnim(animName);

            if (anim == null || !anim.IsVaild)
            {
                return;
            }
            mSprites = new Sprite[anim.m_Frames.Length];
            for (int i = 0; i < mSprites.Length; i++)
            {
                mSprites[i] = m_Atlas.GetSprite(anim.m_Frames[i].m_Sprite);
            }
            mCurrentAnim = anim;
            mTime        = 0;
            mFrame       = 0;
            var spr = mSprites[mFrame];

            if (spr != null)
            {
                mPlayer.sprite = spr;
            }
        }
Exemplo n.º 3
0
        void OnFrameGUI(EmojiAnims.Anim anim)
        {
            EditorGUILayout.BeginVertical("Icon.ClipSelected");
            var frames = anim.m_Frames;

            if (frames == null || frames.Length == 0)
            {
                frames             = new EmojiAnims.Frame[1];
                frames[0]          = new EmojiAnims.Frame();
                frames[0].m_Sprite = anim.m_Name;
                anim.m_Frames      = frames;
            }
            for (int i = 0; i < frames.Length; i++)
            {
                var frame = frames[i];
                EditorGUILayout.BeginHorizontal();
                bool del = GUILayout.Button("", "OL Minus", GUILayout.Width(20));
                EditorGUILayout.LabelField(StringUtil.FormatTime(anim.m_Duration * i));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                bool add = GUILayout.Button("", "OL Plus", GUILayout.Width(20));
                EditorGUILayout.LabelField("sprite", GUILayout.Width(40));
                var spr = EditorGUILayout.TextField(frame.m_Sprite);
                mDirty        |= spr != frame.m_Sprite;
                frame.m_Sprite = spr;
                EditorGUILayout.LabelField("rotate", GUILayout.Width(40));
                var rot = EditorGUILayout.FloatField(frame.m_Rotate);
                mDirty        |= rot != frame.m_Rotate;
                frame.m_Rotate = rot;
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(5);
                if (add)
                {
                    var newf = new EmojiAnims.Frame();
                    newf.m_Sprite = frame.m_Sprite;
                    newf.m_Rotate = frame.m_Rotate;
                    GlobalUtil.Insert(ref frames, i + 1, newf);
                    anim.m_Frames = frames;
                    mDirty        = true;
                    GUI.FocusControl(null);
                    break;
                }
                else if (del)
                {
                    GlobalUtil.RemoveAt(ref frames, i);
                    anim.m_Frames = frames;
                    mDirty        = true;
                    GUI.FocusControl(null);
                    break;
                }
            }
            GUILayout.Space(5);
            EditorGUILayout.EndVertical();
        }
Exemplo n.º 4
0
 void RemoveAnim(int index)
 {
     if (mTarget.m_Anims != null && index < mTarget.m_Anims.Length)
     {
         var anims = new EmojiAnims.Anim[mTarget.m_Anims.Length - 1];
         if (index > 0)
         {
             System.Array.Copy(mTarget.m_Anims, anims, index);
         }
         if (index < anims.Length)
         {
             System.Array.Copy(mTarget.m_Anims, index + 1, anims, index, anims.Length - index);
         }
         mTarget.m_Anims = anims;
         mDirty          = true;
     }
 }
 private void OnDestroy()
 {
     mPlayer      = null;
     mSprites     = null;
     mCurrentAnim = null;
 }