void CreateNewSkin() { serializedObject.Update(); Skin newSkin = ScriptableObjectUtility.CreateAssetWithSavePanel <Skin>("Create a skin asset", "skin.asset", "asset", "Create a new Skin"); mList.serializedProperty.arraySize += 1; SerializedProperty newElement = mList.serializedProperty.GetArrayElementAtIndex(mList.serializedProperty.arraySize - 1); newElement.objectReferenceValue = newSkin; serializedObject.ApplyModifiedProperties(); SkinUtils.SavePose(newSkin, (target as SkinManager).transform); }
void SetupList() { SerializedProperty skinListProperty = serializedObject.FindProperty("m_Skins"); if (skinListProperty != null) { mList = new ReorderableList(serializedObject, skinListProperty, true, true, true, true); mList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { SerializedProperty poseProperty = mList.serializedProperty.GetArrayElementAtIndex(index); rect.y += 1.5f; EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width - 120, EditorGUIUtility.singleLineHeight), poseProperty, GUIContent.none); EditorGUI.BeginDisabledGroup(!poseProperty.objectReferenceValue); if (GUI.Button(new Rect(rect.x + rect.width - 115, rect.y, 55, EditorGUIUtility.singleLineHeight), "Save")) { if (EditorUtility.DisplayDialog("Overwrite Pose", "Overwrite '" + poseProperty.objectReferenceValue.name + "'?", "Apply", "Cancel")) { SkinUtils.SavePose(poseProperty.objectReferenceValue as Skin, (target as SkinManager).transform); mList.index = index; } } if (GUI.Button(new Rect(rect.x + rect.width - 55, rect.y, 55, EditorGUIUtility.singleLineHeight), "Load")) { SkinUtils.LoadPose(poseProperty.objectReferenceValue as Skin, (target as SkinManager).transform); mList.index = index; } EditorGUI.EndDisabledGroup(); }; mList.drawHeaderCallback = (Rect rect) => { EditorGUI.LabelField(rect, "Skins"); }; mList.onSelectCallback = (ReorderableList list) => { }; } }