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); } }
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); }
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); }
public void OnEnable() { EditorTickManager.Add(update); }
public PreviewSystem() { EditorTickManager.Add(update); }
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(); } }