public static void ObjectField <T>(string title, T content, bool allowSceneObject, bool showRemoveButton, Action <T> onValueChanged, Func <bool> validate, params GUILayoutOption[] options) where T : Object { EditorGUI.BeginChangeCheck(); EditorCustomGUI.BeginErrorCheck(validate); T value; if (showRemoveButton) { EditorGUILayout.BeginHorizontal(); value = (T)EditorGUILayout.ObjectField(title, content, typeof(T), allowSceneObject, options); EditorCustomGUI.EndErrorCheck(); if (GUILayout.Button("×", EditorCustomGUI.RemoveButtonStyle, GUILayout.Width(25), GUILayout.Height(EditorGUIUtility.singleLineHeight))) { value = default; } EditorGUILayout.EndHorizontal(); } else { value = (T)EditorGUILayout.ObjectField(title, content, typeof(T), allowSceneObject, options); EditorCustomGUI.EndErrorCheck(); } if (!EditorGUI.EndChangeCheck()) { return; } onValueChanged.Invoke(value); }
public static void TextField(string title, string text, Action <string> onValueChanged, Func <bool> validate) { EditorGUI.BeginChangeCheck(); EditorCustomGUI.BeginErrorCheck(validate); var value = EditorGUILayout.TextField(title, text); EditorCustomGUI.EndErrorCheck(); if (!EditorGUI.EndChangeCheck()) { return; } onValueChanged.Invoke(value); }
public static void FolderPathField(string label, string text, string title, Action <string> onValueChanged, Func <bool> validate) { using (new EditorGUILayout.HorizontalScope()) { EditorGUI.BeginChangeCheck(); EditorCustomGUI.BeginErrorCheck(validate); var value = EditorGUILayout.TextField(label, text); EditorCustomGUI.EndErrorCheck(); if (EditorGUI.EndChangeCheck()) { onValueChanged.Invoke(value); } if (GUILayout.Button("...", EditorStyles.miniButton, GUILayout.Width(30))) { onValueChanged(FolderUtil.GetSaveFolderPath(title)); } } }