Example #1
0
        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);
        }
Example #2
0
        /// <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);
        }
Example #3
0
        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);
            }
        }