[unity] Some editor fixes.

This commit is contained in:
pharan 2017-05-18 09:52:13 +08:00
parent 5d78359b7c
commit 2cb188e568
3 changed files with 21 additions and 4 deletions

View File

@ -41,7 +41,7 @@ namespace Spine.Unity.Editor {
[CustomEditor(typeof(SkeletonRenderer))] [CustomEditor(typeof(SkeletonRenderer))]
[CanEditMultipleObjects] [CanEditMultipleObjects]
public class SkeletonRendererInspector : UnityEditor.Editor { public class SkeletonRendererInspector : UnityEditor.Editor {
protected static bool advancedFoldout; public static bool advancedFoldout;
protected SerializedProperty skeletonDataAsset, initialSkinName; protected SerializedProperty skeletonDataAsset, initialSkinName;
protected SerializedProperty initialFlipX, initialFlipY; protected SerializedProperty initialFlipX, initialFlipY;
@ -278,7 +278,7 @@ namespace Spine.Unity.Editor {
using (new SpineInspectorUtility.LabelWidthScope()) { using (new SpineInspectorUtility.LabelWidthScope()) {
// Optimization options // Optimization options
if (singleSubmesh != null) EditorGUILayout.PropertyField(singleSubmesh, SingleSubmeshLabel); if (singleSubmesh != null) EditorGUILayout.PropertyField(singleSubmesh, SingleSubmeshLabel);
if (meshes != null) EditorGUILayout.PropertyField(meshes, MeshesLabel); //if (meshes != null) EditorGUILayout.PropertyField(meshes, MeshesLabel);
if (immutableTriangles != null) EditorGUILayout.PropertyField(immutableTriangles, ImmubleTrianglesLabel); if (immutableTriangles != null) EditorGUILayout.PropertyField(immutableTriangles, ImmubleTrianglesLabel);
EditorGUILayout.PropertyField(clearStateOnDisable, ClearStateOnDisableLabel); EditorGUILayout.PropertyField(clearStateOnDisable, ClearStateOnDisableLabel);
EditorGUILayout.Space(); EditorGUILayout.Space();

View File

@ -68,6 +68,7 @@ namespace Spine.Unity.Editor {
freeze_ = so.FindProperty("freeze"); freeze_ = so.FindProperty("freeze");
meshGeneratorSettings_ = so.FindProperty("meshGenerator").FindPropertyRelative("settings"); meshGeneratorSettings_ = so.FindProperty("meshGenerator").FindPropertyRelative("settings");
meshGeneratorSettings_.isExpanded = SkeletonRendererInspector.advancedFoldout;
} }
public override void OnInspectorGUI () { public override void OnInspectorGUI () {
@ -85,6 +86,7 @@ namespace Spine.Unity.Editor {
} }
using (new SpineInspectorUtility.BoxScope()) { using (new SpineInspectorUtility.BoxScope()) {
EditorGUILayout.PropertyField(meshGeneratorSettings_, SpineInspectorUtility.TempContent("Advanced..."), includeChildren: true); EditorGUILayout.PropertyField(meshGeneratorSettings_, SpineInspectorUtility.TempContent("Advanced..."), includeChildren: true);
SkeletonRendererInspector.advancedFoldout = meshGeneratorSettings_.isExpanded;
} }
EditorGUILayout.Space(); EditorGUILayout.Space();

View File

@ -50,7 +50,6 @@ namespace Spine.Unity {
public float timeScale = 1f; public float timeScale = 1f;
public bool freeze; public bool freeze;
public bool unscaledTime; public bool unscaledTime;
//public bool tintBlack = false;
#if UNITY_EDITOR #if UNITY_EDITOR
protected override void OnValidate () { protected override void OnValidate () {
@ -204,8 +203,24 @@ namespace Spine.Unity {
if (!string.IsNullOrEmpty(initialSkinName)) if (!string.IsNullOrEmpty(initialSkinName))
skeleton.SetSkin(initialSkinName); skeleton.SetSkin(initialSkinName);
if (!string.IsNullOrEmpty(startingAnimation)) #if UNITY_EDITOR
if (!string.IsNullOrEmpty(startingAnimation)) {
if (Application.isPlaying) {
state.SetAnimation(0, startingAnimation, startingLoop); state.SetAnimation(0, startingAnimation, startingLoop);
} else {
// Assume SkeletonAnimation is valid for skeletonData and skeleton. Checked above.
var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(startingAnimation);
if (animationObject != null)
animationObject.Apply(skeleton, 0f, 0f, false, null, 1f, true, false);
}
Update(0);
}
#else
if (!string.IsNullOrEmpty(startingAnimation)) {
state.SetAnimation(0, startingAnimation, startingLoop);
Update(0);
}
#endif
} }
public void UpdateMesh () { public void UpdateMesh () {