Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 2
0
        public static void Add(Action handler, float delayTime = 0.016f)
        {
            if (delayTime <= 0)
            {
                handler();
                return;
            }
            if (delayTime < 0.016f)
            {
                delayTime = 0.016f;
            }

            float t = (float)EditorTickManager.getTimer() + delayTime;

            foreach (ActionNode <float> node in updateQueue)
            {
                if (node.action == handler)
                {
                    node.data = t;
                    return;
                }
            }

            ActionNode <float> actionNode = new ActionNode <float>();

            actionNode.action = handler;
            actionNode.data   = t;

            updateQueue.Add(actionNode);

            if (updateQueue.Count > 0)
            {
                EditorTickManager.Add(Update);
            }
        }
Ejemplo n.º 3
0
        public void Stop()
        {
            EditorTickManager.Remove(update);

            if (particleSystems != null && go != null)
            {
                foreach (ParticleSystem particleSystem in particleSystems)
                {
                    particleSystem.Stop();
                }
            }
            _runningTime    = 0;
            particleSystems = null;
        }
Ejemplo n.º 4
0
        public void Play(List <ParticleSystem> list, GameObject go)
        {
            this.go = go;
            if (particleSystems != null)
            {
                foreach (ParticleSystem item in particleSystems)
                {
                    item.Simulate(0);
                }
            }

            this.particleSystems = list;

            _runningTime = 0;

            EditorTickManager.Add(update);
        }
Ejemplo n.º 5
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);
                }
            }
        }
Ejemplo n.º 6
0
        public void Play(AnimationClip clip, GameObject go, bool isLooping = false)
        {
            this.animationClip = clip;
            this.go            = go;
            this.isLooping     = isLooping;

            if (this.animationClip.legacy == false)
            {
                animator             = go.GetComponentInChildren <Animator>();
                animator.fireEvents  = false;
                animator.logWarnings = false;
                animator.enabled     = false;
                animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;

                RuntimeAnimatorController runtimeAnimatorController = animator.runtimeAnimatorController;
                hasState = false;
                if (runtimeAnimatorController != null)
                {
                    foreach (AnimationClip item in runtimeAnimatorController.animationClips)
                    {
                        if (item.name == clip.name)
                        {
                            hasState = true;
                        }
                    }
                }
                if (hasState == false)
                {
                    parentEditorWindow.ShowNotification(new GUIContent("animator not exist state:" + clip.name));
                }
            }
            else
            {
                hasState = false;
                animator = null;
            }

            _runningTime = 0;
            _duration    = clip.length;
            EditorTickManager.Add(update);
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
0
 public void OnDisable()
 {
     EditorTickManager.Remove(update);
 }
Ejemplo n.º 9
0
 public void OnEnable()
 {
     EditorTickManager.Add(update);
 }
Ejemplo n.º 10
0
 public PreviewSystem()
 {
     EditorTickManager.Add(update);
 }
Ejemplo n.º 11
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();
            }
        }
Ejemplo n.º 12
0
 public void OnDisable()
 {
     EditorTickManager.Remove(tick);
 }
Ejemplo n.º 13
0
 public void Stop()
 {
     EditorTickManager.Remove(update);
 }