public override void OnInspectorGUI() { USprite sp = target as USprite; selectedOption = EditorGUILayout.Popup("Sorting Layer", selectedOption, sortingLayerNames); if (sortingLayerNames[selectedOption] != sp.sortingLayerName) { Undo.RecordObject(sp, "Sorting Layer"); sp.sortingLayerName = sortingLayerNames[selectedOption]; EditorUtility.SetDirty(sp); } int newSortingLayerOrder = EditorGUILayout.IntField("Order in Layer", sp.sortingOrder); if (newSortingLayerOrder != sp.sortingOrder) { Undo.RecordObject(sp, "Edit Sorting Order"); sp.sortingOrder = newSortingLayerOrder; EditorUtility.SetDirty(sp); } serializedObject.Update(); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Sprite"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Color"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Material"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Pivot"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_skewX"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_skewY"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RotatePerspective"), true); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_PerspectiveRange"), true); serializedObject.ApplyModifiedProperties(); }
void OnEnable() { USprite sp = target as USprite; sortingLayerNames = GetSortingLayerNames(); selectedOption = GetSortingLayerIndex(sp.sortingLayerName); }