private void DrawName(Rect rect, INamedData nameable) { GUIStyle labelStyle = new GUIStyle(EditorStyles.label) { fontStyle = FontStyle.Bold, fontSize = 12, padding = new RectOffset(4, 0, 0, 0) }; EditorGUI.LabelField(rect, GetTypeNameLabel(nameable, nameable.GetType()), labelStyle); }
/// <inheritdoc /> protected override float DrawLabel(Rect rect, object currentValue, Action <object> changeValueCallback, GUIContent label) { INamedData nameable = currentValue as INamedData; Rect nameRect = rect; nameRect.width = EditorGUIUtility.labelWidth; Rect typeRect = rect; typeRect.x += EditorGUIUtility.labelWidth; typeRect.width -= EditorGUIUtility.labelWidth; GUIStyle textFieldStyle = new GUIStyle(EditorStyles.textField) { fontStyle = FontStyle.Bold, fontSize = 12 }; string newName = EditorGUI.DelayedTextField(nameRect, nameable.Name, textFieldStyle); GUIStyle labelStyle = new GUIStyle(EditorStyles.label) { fontStyle = FontStyle.Bold, fontSize = 12 }; EditorGUI.LabelField(typeRect, GetTypeNameLabel(nameable, nameable.GetType()), labelStyle); if (newName != nameable.Name) { string oldName = nameable.Name; nameable.Name = newName; ChangeValue(() => { nameable.Name = newName; return(nameable); }, () => { nameable.Name = oldName; return(nameable); }, changeValueCallback); } return(rect.height); }
private void DrawRenameable(Rect rect, INamedData nameable, Action <object> changeValueCallback) { Rect nameRect = rect; nameRect.width = EditorGUIUtility.labelWidth; Rect typeRect = rect; typeRect.x += EditorGUIUtility.labelWidth; typeRect.width -= EditorGUIUtility.labelWidth; GUIStyle textFieldStyle = new GUIStyle(EditorStyles.textField) { fontStyle = FontStyle.Bold, fontSize = 12 }; string newName = EditorGUI.DelayedTextField(nameRect, nameable.Name, textFieldStyle); GUIStyle labelStyle = new GUIStyle(EditorStyles.label) { fontStyle = FontStyle.Bold, fontSize = 12, padding = new RectOffset(4, 0, 0, 0) }; EditorGUI.LabelField(typeRect, GetTypeNameLabel(nameable, nameable.GetType()), labelStyle); if (newName != nameable.Name) { string oldName = nameable.Name; nameable.Name = newName; ChangeValue(() => { nameable.Name = newName; return(nameable); }, () => { nameable.Name = oldName; return(nameable); }, changeValueCallback); } }