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