Added SkeletonUtility button to SkeletonAnimatorInspector

This commit is contained in:
Fenrisul 2015-02-17 18:36:56 -08:00
parent 9c7b95ff30
commit 678296a3d7

View File

@ -40,10 +40,13 @@ using Spine;
[CustomEditor(typeof(SkeletonAnimator))]
public class SkeletonAnimatorInspector : SkeletonRendererInspector {
protected SerializedProperty layerMixModes;
protected bool isPrefab;
protected override void OnEnable () {
base.OnEnable();
layerMixModes = serializedObject.FindProperty("layerMixModes");
if (PrefabUtility.GetPrefabType(this.target) == PrefabType.Prefab)
isPrefab = true;
}
protected override void gui () {
@ -51,6 +54,18 @@ public class SkeletonAnimatorInspector : SkeletonRendererInspector {
EditorGUILayout.PropertyField(layerMixModes, true);
serializedObject.ApplyModifiedProperties();
SkeletonAnimator component = (SkeletonAnimator)target;
if (!component.valid)
return;
EditorGUILayout.Space();
if (!isPrefab) {
if (component.GetComponent<SkeletonUtility>() == null) {
if (GUILayout.Button(new GUIContent("Add Skeleton Utility", SpineEditorUtilities.Icons.skeletonUtility), GUILayout.Height(30))) {
component.gameObject.AddComponent<SkeletonUtility>();
}
}
}
}
}