|
@@ -37,6 +37,7 @@ namespace Spine.Unity.Editor {
|
|
[CanEditMultipleObjects]
|
|
[CanEditMultipleObjects]
|
|
public class SkeletonMecanimInspector : SkeletonRendererInspector {
|
|
public class SkeletonMecanimInspector : SkeletonRendererInspector {
|
|
public static bool mecanimSettingsFoldout;
|
|
public static bool mecanimSettingsFoldout;
|
|
|
|
+ public static bool enableScenePreview;
|
|
|
|
|
|
protected SerializedProperty autoReset;
|
|
protected SerializedProperty autoReset;
|
|
protected SerializedProperty useCustomMixMode;
|
|
protected SerializedProperty useCustomMixMode;
|
|
@@ -53,7 +54,6 @@ namespace Spine.Unity.Editor {
|
|
}
|
|
}
|
|
|
|
|
|
protected override void DrawInspectorGUI (bool multi) {
|
|
protected override void DrawInspectorGUI (bool multi) {
|
|
-
|
|
|
|
AddRootMotionComponentIfEnabled();
|
|
AddRootMotionComponentIfEnabled();
|
|
|
|
|
|
base.DrawInspectorGUI(multi);
|
|
base.DrawInspectorGUI(multi);
|
|
@@ -75,6 +75,18 @@ namespace Spine.Unity.Editor {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ EditorGUI.BeginChangeCheck();
|
|
|
|
+ enableScenePreview = EditorGUILayout.Toggle(new GUIContent("Scene Preview",
|
|
|
|
+ "Preview the Animation Clip selected in the Animation window. Lock this SkeletonMecanim Inspector " +
|
|
|
|
+ "window, open the Animation window and select the Animation Clip. Then in the Animation window " +
|
|
|
|
+ "scrub through the timeline."),
|
|
|
|
+ enableScenePreview, GUILayout.MaxWidth(150f));
|
|
|
|
+ bool wasScenePreviewChanged = EditorGUI.EndChangeCheck();
|
|
|
|
+ if (enableScenePreview)
|
|
|
|
+ HandleAnimationPreview();
|
|
|
|
+ else if (wasScenePreviewChanged) // just disabled, back to setup pose
|
|
|
|
+ PreviewAnimationInScene(null, 0.0f);
|
|
}
|
|
}
|
|
|
|
|
|
protected void AddRootMotionComponentIfEnabled () {
|
|
protected void AddRootMotionComponentIfEnabled () {
|
|
@@ -89,6 +101,39 @@ namespace Spine.Unity.Editor {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ protected void HandleAnimationPreview () {
|
|
|
|
+ UnityEngine.Object animationWindow = AnimationWindowPreview.GetOpenAnimationWindow();
|
|
|
|
+
|
|
|
|
+ AnimationClip selectedClip = null;
|
|
|
|
+ if (animationWindow != null) {
|
|
|
|
+ selectedClip = AnimationWindowPreview.GetAnimationClip(animationWindow);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (selectedClip != null) {
|
|
|
|
+ float time = AnimationWindowPreview.GetAnimationTime(animationWindow);
|
|
|
|
+ PreviewAnimationInScene(selectedClip, time);
|
|
|
|
+ }
|
|
|
|
+ else // back to setup pose
|
|
|
|
+ PreviewAnimationInScene(null, 0.0f);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected void PreviewAnimationInScene (AnimationClip clip, float time) {
|
|
|
|
+ foreach (UnityEngine.Object c in targets) {
|
|
|
|
+ SkeletonRenderer skeletonRenderer = c as SkeletonRenderer;
|
|
|
|
+ if (skeletonRenderer == null) continue;
|
|
|
|
+ Skeleton skeleton = skeletonRenderer.Skeleton;
|
|
|
|
+ SkeletonData skeletonData = skeleton.Data;
|
|
|
|
+
|
|
|
|
+ skeleton.SetToSetupPose();
|
|
|
|
+ if (clip != null) {
|
|
|
|
+ Spine.Animation animation = skeletonData.FindAnimation(clip.name);
|
|
|
|
+ animation.Apply(skeleton, 0, time, false, null, 1.0f, MixBlend.First, MixDirection.In);
|
|
|
|
+ }
|
|
|
|
+ skeletonRenderer.LateUpdate();
|
|
|
|
+ }
|
|
|
|
+ SceneView.RepaintAll();
|
|
|
|
+ }
|
|
|
|
+
|
|
protected void DrawLayerSettings () {
|
|
protected void DrawLayerSettings () {
|
|
string[] layerNames = GetLayerNames();
|
|
string[] layerNames = GetLayerNames();
|
|
float widthLayerColumn = 140;
|
|
float widthLayerColumn = 140;
|