mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
Reload button and default mix time.
This commit is contained in:
parent
147c9bd763
commit
968f408445
@ -41,7 +41,6 @@ public class BoneComponentInspector : Editor {
|
|||||||
boneName = serializedObject.FindProperty("boneName");
|
boneName = serializedObject.FindProperty("boneName");
|
||||||
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
||||||
followZPosition = serializedObject.FindProperty("followZPosition");
|
followZPosition = serializedObject.FindProperty("followZPosition");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public void OnInspectorGUI () {
|
override public void OnInspectorGUI () {
|
||||||
|
|||||||
@ -35,7 +35,7 @@ using Spine;
|
|||||||
|
|
||||||
[CustomEditor(typeof(SkeletonDataAsset))]
|
[CustomEditor(typeof(SkeletonDataAsset))]
|
||||||
public class SkeletonDataAssetInspector : Editor {
|
public class SkeletonDataAssetInspector : Editor {
|
||||||
private SerializedProperty spriteCollection, skeletonJSON, scale, fromAnimation, toAnimation, duration;
|
private SerializedProperty spriteCollection, skeletonJSON, scale, fromAnimation, toAnimation, duration, defaultMix;
|
||||||
private bool showAnimationStateData = true;
|
private bool showAnimationStateData = true;
|
||||||
|
|
||||||
void OnEnable () {
|
void OnEnable () {
|
||||||
@ -45,6 +45,7 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
fromAnimation = serializedObject.FindProperty("fromAnimation");
|
fromAnimation = serializedObject.FindProperty("fromAnimation");
|
||||||
toAnimation = serializedObject.FindProperty("toAnimation");
|
toAnimation = serializedObject.FindProperty("toAnimation");
|
||||||
duration = serializedObject.FindProperty("duration");
|
duration = serializedObject.FindProperty("duration");
|
||||||
|
defaultMix = serializedObject.FindProperty("defaultMix");
|
||||||
}
|
}
|
||||||
|
|
||||||
override public void OnInspectorGUI () {
|
override public void OnInspectorGUI () {
|
||||||
@ -62,6 +63,8 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
if (skeletonData != null) {
|
if (skeletonData != null) {
|
||||||
showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
|
showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
|
||||||
if (showAnimationStateData) {
|
if (showAnimationStateData) {
|
||||||
|
EditorGUILayout.PropertyField(defaultMix);
|
||||||
|
|
||||||
// Animation names.
|
// Animation names.
|
||||||
String[] animations = new String[skeletonData.Animations.Count];
|
String[] animations = new String[skeletonData.Animations.Count];
|
||||||
for (int i = 0; i < animations.Length; i++)
|
for (int i = 0; i < animations.Length; i++)
|
||||||
@ -98,7 +101,7 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
if (serializedObject.ApplyModifiedProperties() ||
|
if (serializedObject.ApplyModifiedProperties() ||
|
||||||
(UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
|
(UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
|
||||||
) {
|
) {
|
||||||
asset.Clear();
|
asset.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,23 +46,26 @@ public class SkeletonRendererInspector : Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void gui () {
|
protected virtual void gui () {
|
||||||
EditorGUILayout.PropertyField(skeletonDataAsset);
|
|
||||||
|
|
||||||
SkeletonRenderer component = (SkeletonRenderer)target;
|
SkeletonRenderer component = (SkeletonRenderer)target;
|
||||||
|
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
EditorGUILayout.PropertyField(skeletonDataAsset);
|
||||||
|
float reloadWidth = GUI.skin.label.CalcSize(new GUIContent("Reload")).x + 20;
|
||||||
|
if (GUILayout.Button("Reload", GUILayout.Width(reloadWidth))) {
|
||||||
|
if (component.skeletonDataAsset != null) {
|
||||||
|
component.skeletonDataAsset.Reset();
|
||||||
|
}
|
||||||
|
component.Reset();
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
if (!component.valid) {
|
if (!component.valid) {
|
||||||
component.Reset();
|
component.Reset();
|
||||||
component.LateUpdate();
|
component.LateUpdate();
|
||||||
if (!component.valid) {
|
if (!component.valid) return;
|
||||||
EditorGUILayout.BeginHorizontal();
|
|
||||||
EditorGUILayout.Space();
|
|
||||||
if (GUILayout.Button("Refresh")) component.Reset();
|
|
||||||
EditorGUILayout.Space();
|
|
||||||
EditorGUILayout.EndHorizontal();
|
|
||||||
EditorGUILayout.Space();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Initial skin name.
|
// Initial skin name.
|
||||||
{
|
{
|
||||||
String[] skins = new String[component.skeleton.Data.Skins.Count];
|
String[] skins = new String[component.skeleton.Data.Skins.Count];
|
||||||
|
|||||||
@ -41,10 +41,11 @@ public class SkeletonDataAsset : ScriptableObject {
|
|||||||
public String[] fromAnimation;
|
public String[] fromAnimation;
|
||||||
public String[] toAnimation;
|
public String[] toAnimation;
|
||||||
public float[] duration;
|
public float[] duration;
|
||||||
|
public float defaultMix;
|
||||||
private SkeletonData skeletonData;
|
private SkeletonData skeletonData;
|
||||||
private AnimationStateData stateData;
|
private AnimationStateData stateData;
|
||||||
|
|
||||||
public void Clear () {
|
public void Reset () {
|
||||||
skeletonData = null;
|
skeletonData = null;
|
||||||
stateData = null;
|
stateData = null;
|
||||||
}
|
}
|
||||||
@ -53,14 +54,14 @@ public class SkeletonDataAsset : ScriptableObject {
|
|||||||
if (spriteCollection == null) {
|
if (spriteCollection == null) {
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
Debug.LogError("Sprite collection not set for skeleton data asset: " + name, this);
|
Debug.LogError("Sprite collection not set for skeleton data asset: " + name, this);
|
||||||
Clear();
|
Reset();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skeletonJSON == null) {
|
if (skeletonJSON == null) {
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
Debug.LogError("Skeleton JSON file not set for skeleton data asset: " + name, this);
|
Debug.LogError("Skeleton JSON file not set for skeleton data asset: " + name, this);
|
||||||
Clear();
|
Reset();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,6 +79,7 @@ public class SkeletonDataAsset : ScriptableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stateData = new AnimationStateData(skeletonData);
|
stateData = new AnimationStateData(skeletonData);
|
||||||
|
stateData.DefaultMix = defaultMix;
|
||||||
for (int i = 0, n = fromAnimation.Length; i < n; i++) {
|
for (int i = 0, n = fromAnimation.Length; i < n; i++) {
|
||||||
if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue;
|
if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue;
|
||||||
stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
|
stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public class AtlasAsset : ScriptableObject {
|
|||||||
public Material[] materials;
|
public Material[] materials;
|
||||||
private Atlas atlas;
|
private Atlas atlas;
|
||||||
|
|
||||||
public void Clear () {
|
public void Reset () {
|
||||||
atlas = null;
|
atlas = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,13 +47,13 @@ public class AtlasAsset : ScriptableObject {
|
|||||||
public Atlas GetAtlas () {
|
public Atlas GetAtlas () {
|
||||||
if (atlasFile == null) {
|
if (atlasFile == null) {
|
||||||
Debug.LogError("Atlas file not set for atlas asset: " + name, this);
|
Debug.LogError("Atlas file not set for atlas asset: " + name, this);
|
||||||
Clear();
|
Reset();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (materials == null || materials.Length == 0) {
|
if (materials == null || materials.Length == 0) {
|
||||||
Debug.LogError("Materials not set for atlas asset: " + name, this);
|
Debug.LogError("Materials not set for atlas asset: " + name, this);
|
||||||
Clear();
|
Reset();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,7 +51,7 @@ public class AtlasAssetInspector : Editor {
|
|||||||
if (serializedObject.ApplyModifiedProperties() ||
|
if (serializedObject.ApplyModifiedProperties() ||
|
||||||
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
|
(Event.current.type == EventType.ValidateCommand && Event.current.commandName == "UndoRedoPerformed")
|
||||||
) {
|
) {
|
||||||
asset.Clear();
|
asset.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,7 +41,6 @@ public class BoneComponentInspector : Editor {
|
|||||||
boneName = serializedObject.FindProperty("boneName");
|
boneName = serializedObject.FindProperty("boneName");
|
||||||
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
followBoneRotation = serializedObject.FindProperty("followBoneRotation");
|
||||||
followZPosition = serializedObject.FindProperty("followZPosition");
|
followZPosition = serializedObject.FindProperty("followZPosition");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public void OnInspectorGUI () {
|
override public void OnInspectorGUI () {
|
||||||
|
|||||||
@ -35,7 +35,7 @@ using Spine;
|
|||||||
|
|
||||||
[CustomEditor(typeof(SkeletonDataAsset))]
|
[CustomEditor(typeof(SkeletonDataAsset))]
|
||||||
public class SkeletonDataAssetInspector : Editor {
|
public class SkeletonDataAssetInspector : Editor {
|
||||||
private SerializedProperty atlasAsset, skeletonJSON, scale, fromAnimation, toAnimation, duration;
|
private SerializedProperty atlasAsset, skeletonJSON, scale, fromAnimation, toAnimation, duration, defaultMix;
|
||||||
private bool showAnimationStateData = true;
|
private bool showAnimationStateData = true;
|
||||||
|
|
||||||
void OnEnable () {
|
void OnEnable () {
|
||||||
@ -45,6 +45,7 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
fromAnimation = serializedObject.FindProperty("fromAnimation");
|
fromAnimation = serializedObject.FindProperty("fromAnimation");
|
||||||
toAnimation = serializedObject.FindProperty("toAnimation");
|
toAnimation = serializedObject.FindProperty("toAnimation");
|
||||||
duration = serializedObject.FindProperty("duration");
|
duration = serializedObject.FindProperty("duration");
|
||||||
|
defaultMix = serializedObject.FindProperty("defaultMix");
|
||||||
}
|
}
|
||||||
|
|
||||||
override public void OnInspectorGUI () {
|
override public void OnInspectorGUI () {
|
||||||
@ -59,6 +60,8 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
if (skeletonData != null) {
|
if (skeletonData != null) {
|
||||||
showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
|
showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data");
|
||||||
if (showAnimationStateData) {
|
if (showAnimationStateData) {
|
||||||
|
EditorGUILayout.PropertyField(defaultMix);
|
||||||
|
|
||||||
// Animation names.
|
// Animation names.
|
||||||
String[] animations = new String[skeletonData.Animations.Count];
|
String[] animations = new String[skeletonData.Animations.Count];
|
||||||
for (int i = 0; i < animations.Length; i++)
|
for (int i = 0; i < animations.Length; i++)
|
||||||
@ -95,7 +98,7 @@ public class SkeletonDataAssetInspector : Editor {
|
|||||||
if (serializedObject.ApplyModifiedProperties() ||
|
if (serializedObject.ApplyModifiedProperties() ||
|
||||||
(UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
|
(UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed")
|
||||||
) {
|
) {
|
||||||
asset.Clear();
|
asset.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,21 +46,25 @@ public class SkeletonRendererInspector : Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void gui () {
|
protected virtual void gui () {
|
||||||
EditorGUILayout.PropertyField(skeletonDataAsset);
|
|
||||||
|
|
||||||
SkeletonRenderer component = (SkeletonRenderer)target;
|
SkeletonRenderer component = (SkeletonRenderer)target;
|
||||||
|
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
EditorGUILayout.PropertyField(skeletonDataAsset);
|
||||||
|
float reloadWidth = GUI.skin.label.CalcSize(new GUIContent("Reload")).x + 20;
|
||||||
|
if (GUILayout.Button("Reload", GUILayout.Width(reloadWidth))) {
|
||||||
|
if (component.skeletonDataAsset != null) {
|
||||||
|
if (component.skeletonDataAsset.atlasAsset != null)
|
||||||
|
component.skeletonDataAsset.atlasAsset.Reset();
|
||||||
|
component.skeletonDataAsset.Reset();
|
||||||
|
}
|
||||||
|
component.Reset();
|
||||||
|
}
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
if (!component.valid) {
|
if (!component.valid) {
|
||||||
component.Reset();
|
component.Reset();
|
||||||
component.LateUpdate();
|
component.LateUpdate();
|
||||||
if (!component.valid) {
|
if (!component.valid) return;
|
||||||
EditorGUILayout.BeginHorizontal();
|
|
||||||
EditorGUILayout.Space();
|
|
||||||
if (GUILayout.Button("Refresh")) component.Reset();
|
|
||||||
EditorGUILayout.Space();
|
|
||||||
EditorGUILayout.EndHorizontal();
|
|
||||||
EditorGUILayout.Space();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial skin name.
|
// Initial skin name.
|
||||||
|
|||||||
@ -41,10 +41,11 @@ public class SkeletonDataAsset : ScriptableObject {
|
|||||||
public String[] fromAnimation;
|
public String[] fromAnimation;
|
||||||
public String[] toAnimation;
|
public String[] toAnimation;
|
||||||
public float[] duration;
|
public float[] duration;
|
||||||
|
public float defaultMix;
|
||||||
private SkeletonData skeletonData;
|
private SkeletonData skeletonData;
|
||||||
private AnimationStateData stateData;
|
private AnimationStateData stateData;
|
||||||
|
|
||||||
public void Clear () {
|
public void Reset () {
|
||||||
skeletonData = null;
|
skeletonData = null;
|
||||||
stateData = null;
|
stateData = null;
|
||||||
}
|
}
|
||||||
@ -53,20 +54,20 @@ public class SkeletonDataAsset : ScriptableObject {
|
|||||||
if (atlasAsset == null) {
|
if (atlasAsset == null) {
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
Debug.LogError("Atlas not set for SkeletonData asset: " + name, this);
|
Debug.LogError("Atlas not set for SkeletonData asset: " + name, this);
|
||||||
Clear();
|
Reset();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skeletonJSON == null) {
|
if (skeletonJSON == null) {
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
Debug.LogError("Skeleton JSON file not set for SkeletonData asset: " + name, this);
|
Debug.LogError("Skeleton JSON file not set for SkeletonData asset: " + name, this);
|
||||||
Clear();
|
Reset();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Atlas atlas = atlasAsset.GetAtlas();
|
Atlas atlas = atlasAsset.GetAtlas();
|
||||||
if (atlas == null) {
|
if (atlas == null) {
|
||||||
Clear();
|
Reset();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +85,7 @@ public class SkeletonDataAsset : ScriptableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stateData = new AnimationStateData(skeletonData);
|
stateData = new AnimationStateData(skeletonData);
|
||||||
|
stateData.DefaultMix = defaultMix;
|
||||||
for (int i = 0, n = fromAnimation.Length; i < n; i++) {
|
for (int i = 0, n = fromAnimation.Length; i < n; i++) {
|
||||||
if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue;
|
if (fromAnimation[i].Length == 0 || toAnimation[i].Length == 0) continue;
|
||||||
stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
|
stateData.SetMix(fromAnimation[i], toAnimation[i], duration[i]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user