Пример #1
0
        private static void Update(float deltaTime)
        {
            float c = (float)EditorTickManager.getTimer();

            foreach (ActionNode <float> node in updateQueue)
            {
                if (node.data > c)
                {
                    node.action();
                    todoList.Add(node);
                }
            }

            if (todoList.Count > 0)
            {
                foreach (ActionNode <float> node in todoList)
                {
                    updateQueue.Remove(node);
                }

                if (updateQueue.Count < 1)
                {
                    EditorTickManager.Remove(Update);
                }
            }
        }
Пример #2
0
        public void Stop()
        {
            EditorTickManager.Remove(update);

            if (particleSystems != null && go != null)
            {
                foreach (ParticleSystem particleSystem in particleSystems)
                {
                    particleSystem.Stop();
                }
            }
            _runningTime    = 0;
            particleSystems = null;
        }
Пример #3
0
        private void update(float deltaTime)
        {
            if (parentEditorWindow != null)
            {
                parentEditorWindow.DelayCallRepaint();
            }
            _runningTime += deltaTime;

            if (animationClip == null || go == null)
            {
                Stop();
                return;
            }

            if (animator != null)
            {
                if (_runningTime > _duration)
                {
                    if (isLooping == false && animationClip.isLooping == false)
                    {
                        animator.Play(animationClip.name, 0, 1.0f);
                        animator.Update(deltaTime);
                        EditorTickManager.Remove(update);
                        return;
                    }
                    _runningTime = 0;
                }
                if (hasState)
                {
                    animator.Play(animationClip.name, 0, _runningTime / _duration);
                    animator.Update(deltaTime);
                }
                return;
            }

            animationClip.SampleAnimation(go, _runningTime);
            if (_runningTime > _duration)
            {
                _runningTime = 0;
                if (animationClip.isLooping == false && isLooping == false)
                {
                    animationClip.SampleAnimation(go, _runningTime);
                    EditorTickManager.Remove(update);
                }
            }
        }
Пример #4
0
        public static void Remove(Action handler)
        {
            int index = -1;
            int i     = 0;

            foreach (ActionNode <float> node in updateQueue)
            {
                if (node.action == handler)
                {
                    index = i;
                    break;
                }
                i++;
            }
            if (index != -1)
            {
                updateQueue.RemoveAt(index);
            }

            if (updateQueue.Count < 1)
            {
                EditorTickManager.Remove(Update);
            }
        }
Пример #5
0
 public void OnDisable()
 {
     EditorTickManager.Remove(update);
 }
Пример #6
0
        public override void OnInspectorGUI()
        {
            if (upkAniVo == null)
            {
                return;
            }

            isPlaying = EditorGUILayout.ToggleLeft("playing", isPlaying, GUILayout.Width(50));

            upkAniVo.fps = EditorGUILayout.IntSlider(upkAniVo.fps, 1, 60);
            if (isPlaying)
            {
                EditorTickManager.Add(tick);
            }
            else
            {
                EditorTickManager.Remove(tick);
            }

            _currentFrame = _currentFrame % _totalFrame;

            SpriteInfoVO spriteInfoVO = upkAniVo.keys[_currentFrame];
            Sprite       sprite       = spriteInfoVO.sprite;

            if (isPlaying == false)
            {
                spriteInfoVO.delay = EditorGUILayout.FloatField("delay", spriteInfoVO.delay);
            }

            EditorGUILayout.BeginHorizontal();
            upkAniVo.loop = EditorGUILayout.ToggleLeft("loop", upkAniVo.loop, GUILayout.Width(50));
            GUILayout.FlexibleSpace();
            GUIStyle style = EditorStyles.miniButton;

            if (isPlaying == false)
            {
                if (GUILayout.Button("prev", EditorStyles.miniButtonLeft))
                {
                    _currentFrame--;
                    if (_currentFrame < 0)
                    {
                        _currentFrame = _totalFrame - 1;
                    }
                }
                if (GUILayout.Button("next", EditorStyles.miniButtonMid))
                {
                    _currentFrame++;
                    if (_currentFrame > _totalFrame - 1)
                    {
                        _currentFrame = 0;
                    }
                }
                style = EditorStyles.miniButtonRight;
            }

            if (GUILayout.Button("save", style))
            {
                EditorUtility.SetDirty(upkAniVo);
                AssetDatabase.SaveAssets();
            }



            EditorGUILayout.EndHorizontal();

            Rect rect = GUILayoutUtility.GetLastRect();

            rect.y += rect.height + 100;

            rect.width  = 300;
            rect.height = 300;
            rect.x      = (Screen.width - rect.width) / 2;

            Rect labelRect = rect;

            labelRect.height = 20;
            EditorGUI.LabelField(rect, sprite.name + "(" + (_currentFrame + 1) + "/" + _totalFrame + ")");

            EditorUtils.DrawSprite(rect, sprite, true);
            if (isPlaying)
            {
                HandleUtility.Repaint();
            }
        }
Пример #7
0
 public void OnDisable()
 {
     EditorTickManager.Remove(tick);
 }
Пример #8
0
 public void Stop()
 {
     EditorTickManager.Remove(update);
 }