[Unity] Autoreset will be a separate script until we clear up mixing stuff. Sorry for the confusion!

This commit is contained in:
pharan 2016-01-05 15:41:10 +08:00
parent f0d1b75732
commit 8c7038c0b9
2 changed files with 11 additions and 10 deletions

View File

@ -45,8 +45,6 @@ public class SkeletonAnimationInspector : SkeletonRendererInspector {
animationName = serializedObject.FindProperty("_animationName");
loop = serializedObject.FindProperty("loop");
timeScale = serializedObject.FindProperty("timeScale");
autoReset = serializedObject.FindProperty("autoReset");
autoResetLabel = new GUIContent("Generic Auto-reset");
if (PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab)
m_isPrefab = true;
@ -97,7 +95,6 @@ public class SkeletonAnimationInspector : SkeletonRendererInspector {
EditorGUILayout.PropertyField(loop);
EditorGUILayout.PropertyField(timeScale);
EditorGUILayout.PropertyField(autoReset, autoResetLabel);
component.timeScale = Math.Max(component.timeScale, 0);
EditorGUILayout.Space();

View File

@ -111,9 +111,9 @@ public class SkeletonAnimation : SkeletonRenderer, ISkeletonAnimation {
#endif
public float timeScale = 1;
#if UNITY_5
#region AutoReset
/**
[Tooltip("Setting this to true makes the SkeletonAnimation behave similar to Spine editor. New animations will not inherit the pose from a previous animation. If you need to intermittently and programmatically pose your skeleton, leave this false.")]
#endif
[SerializeField]
protected bool autoReset = false;
@ -132,6 +132,13 @@ public class SkeletonAnimation : SkeletonRenderer, ISkeletonAnimation {
}
}
protected virtual void HandleNewAnimationAutoreset (Spine.AnimationState state, int trackIndex) {
if (!autoReset) return;
if (skeleton != null) skeleton.SetToSetupPose();
}
*/
#endregion
public override void Reset () {
base.Reset();
if (!valid)
@ -139,20 +146,17 @@ public class SkeletonAnimation : SkeletonRenderer, ISkeletonAnimation {
state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
/*
if (autoReset) {
state.Start += HandleNewAnimationAutoreset;
}
*/
if (_animationName != null && _animationName.Length > 0) {
state.SetAnimation(0, _animationName, loop);
Update(0);
}
}
protected virtual void HandleNewAnimationAutoreset (Spine.AnimationState state, int trackIndex) {
if (!autoReset) return;
if (skeleton != null) skeleton.SetToSetupPose();
}
public virtual void Update () {
Update(Time.deltaTime);