protected override void Update() { if (animation == null && _animationName != null) { animation = OT.AnimationByName(_animationName); } if (spriteContainer != null && !spriteContainer.isReady) { return; } if (speed < 0) { speed = 0; } if (Application.isPlaying && animation != null && animation.isReady && _playing) { if (waiting) { HandleWaiting(); } if (!waiting) { UpdateFrame(); } } else { EditorPreview(); } base.Update(); }
void RegisterAnimation() { if (OT.AnimationByName(name) == null) { OT.RegisterAnimation(this); gameObject.name = name; registered = true; } if (_name_ != name) { OT.RegisterAnimationLookup(this, _name_); _name_ = name; gameObject.name = name; } if (name != gameObject.name) { name = gameObject.name; OT.RegisterAnimationLookup(this, _name_); _name_ = name; #if UNITY_EDITOR if (!Application.isPlaying) { UnityEditor.PrefabUtility.RecordPrefabInstancePropertyModifications(this); } #endif } }
protected override void Update() { if (animation == null && _animationName != null) { animation = OT.AnimationByName(_animationName); } if (animation == null) { return; } if (!animation.isReady) { if (!animation.enabled) { animation.SendMessage("Update"); } return; } if (spriteContainer != null && !spriteContainer.isReady) { return; } if (speed < 0) { speed = 0; } if (Application.isPlaying) { if (_playing) { if (waiting) { HandleWaiting(); } if (!waiting) { UpdateFrame(Time.deltaTime); } } } else { EditorPreview(); } base.Update(); }
void RegisterAnimation() { if (OT.AnimationByName(name) == null) { OT.RegisterAnimation(this); gameObject.name = name; registered = true; } if (_name_ != name) { OT.RegisterAnimationLookup(this, _name_); _name_ = name; gameObject.name = name; } if (name != gameObject.name) { name = gameObject.name; OT.RegisterAnimationLookup(this, _name_); _name_ = name; CheckModifications(); } }
// Update is called once per frame protected override void Update() { if (animation == null && _animationName != null) { animation = OT.AnimationByName(_animationName); } if (spriteContainer != null && !spriteContainer.isReady) { return; } if (speed < 0) { speed = 0; } if (Application.isPlaying && animation != null && animation.isReady && _playing) { if (waiting) { if (waitTime >= delay) { waitTime = 0; delay = 0; if (animationFrameset != "") { frameset = animation.GetFrameset(animationFrameset); frDuration = animation.GetDuration(frameset); frCount = animation.GetFrameCount(frameset); } else { frameset = null; frDuration = animation.duration; frCount = animation.frameCount; } if (frCount == 0) { return; } if (startAtRandomFrame) { time = (frDuration / frCount) * (Mathf.Floor(frCount * Random.value)); } else { if (startFrame != -1) { time = (frDuration / frCount) * startFrame; if (endFrame != -1) { endTime = (frDuration / frCount) * (endFrame + 1) - 0.001f; } } else { time = 0; } } waiting = false; if (onAnimationStart != null) { onAnimationStart(this); } if (!CallBack("onAnimationStart", new object[] { this })) { CallBack("OnAnimationStart", new object[] { this }); } } else { waitTime += Time.deltaTime; } } if (!waiting) { UpdateFrame(); } } else { if (animationPreview < 0) { animationPreview = 0; } else if (animationPreview > 100) { animationPreview = 100; } if (!Application.isPlaying && animation != null && animation.isReady) { if (animationFrameset != "" && (frameset == null || (frameset != null && frameset.name.ToLower() != animationFrameset.ToLower()))) { frameset = animation.GetFrameset(animationFrameset); frCount = animation.GetFrameCount(frameset); } frDuration = animation.GetDuration(frameset); if (frameset != null && frameset.name == "") { frameset = null; } time = ((frDuration / 100) * animationPreview); if (time == frDuration) { time -= 0.001f; } if (time != _time) { UpdateFrame(); _time = time; } } else if (animation != null && animation.isReady) { if (spriteContainer == null) { spriteContainer = animation.GetFrame(0, 1, null).container; } } } base.Update(); }