|
@@ -28,12 +28,18 @@
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*****************************************************************************/
|
|
*****************************************************************************/
|
|
using System;
|
|
using System;
|
|
|
|
+using System.Reflection;
|
|
using UnityEditor;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
|
|
|
|
[CustomEditor(typeof(SkeletonRenderer))]
|
|
[CustomEditor(typeof(SkeletonRenderer))]
|
|
public class SkeletonRendererInspector : Editor {
|
|
public class SkeletonRendererInspector : Editor {
|
|
protected SerializedProperty skeletonDataAsset, initialSkinName, normals, tangents, meshes, immutableTriangles, submeshSeparators, front;
|
|
protected SerializedProperty skeletonDataAsset, initialSkinName, normals, tangents, meshes, immutableTriangles, submeshSeparators, front;
|
|
|
|
+ protected bool advancedFoldout;
|
|
|
|
+
|
|
|
|
+ private static MethodInfo EditorGUILayoutSortingLayerField;
|
|
|
|
+ protected SerializedObject rendererSerializedObject;
|
|
|
|
+ protected SerializedProperty sortingLayerIDProperty;
|
|
|
|
|
|
protected virtual void OnEnable () {
|
|
protected virtual void OnEnable () {
|
|
SpineEditorUtilities.ConfirmInitialization();
|
|
SpineEditorUtilities.ConfirmInitialization();
|
|
@@ -45,6 +51,12 @@ public class SkeletonRendererInspector : Editor {
|
|
immutableTriangles = serializedObject.FindProperty("immutableTriangles");
|
|
immutableTriangles = serializedObject.FindProperty("immutableTriangles");
|
|
submeshSeparators = serializedObject.FindProperty("submeshSeparators");
|
|
submeshSeparators = serializedObject.FindProperty("submeshSeparators");
|
|
front = serializedObject.FindProperty("frontFacing");
|
|
front = serializedObject.FindProperty("frontFacing");
|
|
|
|
+
|
|
|
|
+ if(EditorGUILayoutSortingLayerField == null)
|
|
|
|
+ EditorGUILayoutSortingLayerField = typeof(EditorGUILayout).GetMethod("SortingLayerField", BindingFlags.Static | BindingFlags.NonPublic, null, new Type[] { typeof(GUIContent), typeof(SerializedProperty), typeof(GUIStyle) }, null);
|
|
|
|
+
|
|
|
|
+ rendererSerializedObject = new SerializedObject(((SkeletonRenderer)target).GetComponent<Renderer>());
|
|
|
|
+ sortingLayerIDProperty = rendererSerializedObject.FindProperty("m_SortingLayerID");
|
|
}
|
|
}
|
|
|
|
|
|
protected virtual void gui () {
|
|
protected virtual void gui () {
|
|
@@ -83,23 +95,50 @@ public class SkeletonRendererInspector : Editor {
|
|
if (name == initialSkinName.stringValue)
|
|
if (name == initialSkinName.stringValue)
|
|
skinIndex = i;
|
|
skinIndex = i;
|
|
}
|
|
}
|
|
-
|
|
|
|
- EditorGUILayout.BeginHorizontal();
|
|
|
|
- EditorGUILayout.LabelField("Initial Skin", GUILayout.Width(EditorGUIUtility.labelWidth));
|
|
|
|
- skinIndex = EditorGUILayout.Popup(skinIndex, skins);
|
|
|
|
- EditorGUILayout.EndHorizontal();
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ skinIndex = EditorGUILayout.Popup("Initial Skin", skinIndex, skins);
|
|
initialSkinName.stringValue = skins[skinIndex];
|
|
initialSkinName.stringValue = skins[skinIndex];
|
|
}
|
|
}
|
|
-
|
|
|
|
- EditorGUILayout.PropertyField(meshes,
|
|
|
|
- new GUIContent("Render Meshes", "Disable to optimize rendering for skeletons that don't use meshes"));
|
|
|
|
- EditorGUILayout.PropertyField(immutableTriangles,
|
|
|
|
- new GUIContent("Immutable Triangles", "Enable to optimize rendering for skeletons that never change attachment visbility"));
|
|
|
|
- EditorGUILayout.PropertyField(normals);
|
|
|
|
- EditorGUILayout.PropertyField(tangents);
|
|
|
|
- EditorGUILayout.PropertyField(front);
|
|
|
|
- EditorGUILayout.PropertyField(submeshSeparators, true);
|
|
|
|
|
|
+
|
|
|
|
+ EditorGUILayout.Space();
|
|
|
|
+
|
|
|
|
+ // Sorting Layers
|
|
|
|
+ {
|
|
|
|
+ var renderer = component.GetComponent<Renderer>();
|
|
|
|
+ if(renderer != null) {
|
|
|
|
+ EditorGUI.BeginChangeCheck();
|
|
|
|
+
|
|
|
|
+ if(EditorGUILayoutSortingLayerField != null && sortingLayerIDProperty != null) {
|
|
|
|
+ EditorGUILayoutSortingLayerField.Invoke(null, new object[] { new GUIContent("Sorting Layer"), sortingLayerIDProperty, EditorStyles.popup } );
|
|
|
|
+ } else {
|
|
|
|
+ renderer.sortingLayerID = EditorGUILayout.IntField("Sorting Layer ID", renderer.sortingLayerID);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ renderer.sortingOrder = EditorGUILayout.IntField("Order in Layer", renderer.sortingOrder);
|
|
|
|
+
|
|
|
|
+ if(EditorGUI.EndChangeCheck()) {
|
|
|
|
+ rendererSerializedObject.ApplyModifiedProperties();
|
|
|
|
+ EditorUtility.SetDirty(renderer);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // More Render Options...
|
|
|
|
+ {
|
|
|
|
+ advancedFoldout = EditorGUILayout.Foldout(advancedFoldout, "Advanced");
|
|
|
|
+ if(advancedFoldout) {
|
|
|
|
+ EditorGUI.indentLevel++;
|
|
|
|
+ EditorGUILayout.PropertyField(meshes,
|
|
|
|
+ new GUIContent("Render Meshes", "Disable to optimize rendering for skeletons that don't use meshes"));
|
|
|
|
+ EditorGUILayout.PropertyField(immutableTriangles,
|
|
|
|
+ new GUIContent("Immutable Triangles", "Enable to optimize rendering for skeletons that never change attachment visbility"));
|
|
|
|
+ EditorGUILayout.PropertyField(normals);
|
|
|
|
+ EditorGUILayout.PropertyField(tangents);
|
|
|
|
+ EditorGUILayout.PropertyField(front);
|
|
|
|
+ EditorGUILayout.PropertyField(submeshSeparators, true);
|
|
|
|
+ EditorGUI.indentLevel--;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
override public void OnInspectorGUI () {
|
|
override public void OnInspectorGUI () {
|
|
@@ -112,4 +151,5 @@ public class SkeletonRendererInspector : Editor {
|
|
((SkeletonRenderer)target).Reset();
|
|
((SkeletonRenderer)target).Reset();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|