mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
Deleted useAnimationName. Cleaned up examples.
useAnimationName isn't needed now that animationName is just a property that sets the animation for track zero.
This commit is contained in:
parent
64d50d5edc
commit
9ab690005a
@ -38,13 +38,12 @@ using UnityEngine;
|
||||
[CustomEditor(typeof(SkeletonAnimation))]
|
||||
public class SkeletonAnimationInspector : Editor {
|
||||
private SerializedProperty skeletonDataAsset, initialSkinName, timeScale, normals, tangents;
|
||||
private SerializedProperty animationName, loop, useAnimationName;
|
||||
private SerializedProperty animationName, loop;
|
||||
|
||||
void OnEnable () {
|
||||
skeletonDataAsset = serializedObject.FindProperty("skeletonDataAsset");
|
||||
animationName = serializedObject.FindProperty("_animationName");
|
||||
loop = serializedObject.FindProperty("loop");
|
||||
useAnimationName = serializedObject.FindProperty("useAnimationName");
|
||||
initialSkinName = serializedObject.FindProperty("initialSkinName");
|
||||
timeScale = serializedObject.FindProperty("timeScale");
|
||||
normals = serializedObject.FindProperty("calculateNormals");
|
||||
@ -79,15 +78,14 @@ public class SkeletonAnimationInspector : Editor {
|
||||
initialSkinName.stringValue = skins[skinIndex];
|
||||
|
||||
// Animation name.
|
||||
String[] animations = new String[component.skeleton.Data.Animations.Count + 2];
|
||||
animations[0] = "<No Change>";
|
||||
animations[1] = "<None>";
|
||||
int animationIndex = useAnimationName.boolValue ? 1 : 0;
|
||||
for (int i = 0; i < animations.Length - 2; i++) {
|
||||
String[] animations = new String[component.skeleton.Data.Animations.Count + 1];
|
||||
animations[0] = "<None>";
|
||||
int animationIndex = 0;
|
||||
for (int i = 0; i < animations.Length - 1; i++) {
|
||||
String name = component.skeleton.Data.Animations[i].Name;
|
||||
animations[i + 2] = name;
|
||||
animations[i + 1] = name;
|
||||
if (name == animationName.stringValue)
|
||||
animationIndex = i + 2;
|
||||
animationIndex = i + 1;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
@ -97,16 +95,10 @@ public class SkeletonAnimationInspector : Editor {
|
||||
EditorGUIUtility.LookLikeInspector();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (animationIndex == 0) {
|
||||
if (animationIndex == 0)
|
||||
component.animationName = null;
|
||||
useAnimationName.boolValue = false;
|
||||
} else if (animationIndex == 1) {
|
||||
component.animationName = null;
|
||||
useAnimationName.boolValue = true;
|
||||
} else {
|
||||
else
|
||||
component.animationName = animations[animationIndex];
|
||||
useAnimationName.boolValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Animation loop.
|
||||
|
||||
@ -49,7 +49,6 @@ public class Spineboy : MonoBehaviour {
|
||||
}
|
||||
|
||||
void OnMouseDown() {
|
||||
skeleton.useAnimationName = false;
|
||||
skeleton.state.SetAnimation(0, "jump", false);
|
||||
skeleton.state.AddAnimation(0, "walk", true, 0);
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -38,13 +38,12 @@ using UnityEngine;
|
||||
[CustomEditor(typeof(SkeletonAnimation))]
|
||||
public class SkeletonAnimationInspector : Editor {
|
||||
private SerializedProperty skeletonDataAsset, initialSkinName, timeScale, normals, tangents;
|
||||
private SerializedProperty animationName, loop, useAnimationName;
|
||||
private SerializedProperty animationName, loop;
|
||||
|
||||
void OnEnable () {
|
||||
skeletonDataAsset = serializedObject.FindProperty("skeletonDataAsset");
|
||||
animationName = serializedObject.FindProperty("_animationName");
|
||||
loop = serializedObject.FindProperty("loop");
|
||||
useAnimationName = serializedObject.FindProperty("useAnimationName");
|
||||
initialSkinName = serializedObject.FindProperty("initialSkinName");
|
||||
timeScale = serializedObject.FindProperty("timeScale");
|
||||
normals = serializedObject.FindProperty("calculateNormals");
|
||||
@ -79,15 +78,14 @@ public class SkeletonAnimationInspector : Editor {
|
||||
initialSkinName.stringValue = skins[skinIndex];
|
||||
|
||||
// Animation name.
|
||||
String[] animations = new String[component.skeleton.Data.Animations.Count + 2];
|
||||
animations[0] = "<No Change>";
|
||||
animations[1] = "<None>";
|
||||
int animationIndex = useAnimationName.boolValue ? 1 : 0;
|
||||
for (int i = 0; i < animations.Length - 2; i++) {
|
||||
String[] animations = new String[component.skeleton.Data.Animations.Count + 1];
|
||||
animations[0] = "<None>";
|
||||
int animationIndex = 0;
|
||||
for (int i = 0; i < animations.Length - 1; i++) {
|
||||
String name = component.skeleton.Data.Animations[i].Name;
|
||||
animations[i + 2] = name;
|
||||
animations[i + 1] = name;
|
||||
if (name == animationName.stringValue)
|
||||
animationIndex = i + 2;
|
||||
animationIndex = i + 1;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
@ -97,16 +95,10 @@ public class SkeletonAnimationInspector : Editor {
|
||||
EditorGUIUtility.LookLikeInspector();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (animationIndex == 0) {
|
||||
if (animationIndex == 0)
|
||||
component.animationName = null;
|
||||
useAnimationName.boolValue = false;
|
||||
} else if (animationIndex == 1) {
|
||||
component.animationName = null;
|
||||
useAnimationName.boolValue = true;
|
||||
} else {
|
||||
else
|
||||
component.animationName = animations[animationIndex];
|
||||
useAnimationName.boolValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Animation loop.
|
||||
|
||||
@ -40,7 +40,6 @@ using Spine;
|
||||
/** Extends SkeletonComponent to apply an animation. */
|
||||
[ExecuteInEditMode, RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
|
||||
public class SkeletonAnimation : SkeletonComponent {
|
||||
public bool useAnimationName;
|
||||
public bool loop;
|
||||
public Spine.AnimationState state;
|
||||
|
||||
@ -51,7 +50,6 @@ public class SkeletonAnimation : SkeletonComponent {
|
||||
return entry == null ? null : entry.Animation.Name;
|
||||
}
|
||||
set {
|
||||
if (!useAnimationName) return;
|
||||
if (_animationName == value) return;
|
||||
_animationName = value;
|
||||
if (value == null || value.Length == 0)
|
||||
|
||||
@ -40,9 +40,7 @@ public class Spineboy : MonoBehaviour {
|
||||
SkeletonAnimation skeletonAnimation;
|
||||
|
||||
public void Start () {
|
||||
skeletonAnimation = GetComponent<SkeletonAnimation>();
|
||||
skeletonAnimation.state.SetAnimation(0, "walk", true);
|
||||
|
||||
skeletonAnimation = GetComponent<SkeletonAnimation>();
|
||||
skeletonAnimation.state.Event += new EventHandler<EventTriggeredArgs>(Event);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user