Ejemplo n.º 1
0
        /// <summary>
        /// Draws the given property.
        /// </summary>
        private static void DrawPropertyInternal(SerializedProperty inProperty, PropertyDrawingOptions inOptions = null)
        {
            if (inOptions == null)
            {
                EditorGUILayout.PropertyField(inProperty, true);
                return;
            }

            GUIContent content = ContentFromDrawingOptions(inOptions, inProperty.name);

            // Begin read only block.
            bool previousGUIState;

            BeginReadOnly(out previousGUIState, inOptions.ReadOnly);

            if (inOptions.Rect == null)
            {
                EditorGUILayout.PropertyField(inProperty, content, inOptions.IncludeChildren, inOptions.LayoutOptions);
            }
            else
            {
                EditorGUI.PropertyField(inOptions.Rect.Value, inProperty, content, inOptions.IncludeChildren);
            }

            // End read only block.
            EndReadOnly(previousGUIState);
        }
Ejemplo n.º 2
0
        ////////// GUI LAYOUTING //////////
        ///////////////////////////////////

        /////////////////////////////////////////////////
        ////////// SERIALIZED PROPERTY DRAWING //////////

        private static GUIContent ContentFromDrawingOptions(PropertyDrawingOptions inOptions, string inDefaultLabel)
        {
            if (inOptions == null)
            {
                return(new GUIContent(inDefaultLabel));
            }

            GUIContent content = new GUIContent(GUIContent.none);
            string     label   = inOptions.HideLabel ? null : ObjectNames.NicifyVariableName(inOptions.Label ?? inDefaultLabel);

            if (label != null)
            {
                content.text    = label;
                content.image   = inOptions.Texture;
                content.tooltip = inOptions.Tooltip;
            }

            return(content);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Draws the given property with custom layouting options.
 /// </summary>
 public static void DrawProperty(SerializedProperty inProperty, PropertyDrawingOptions inOptions)
 {
     DrawPropertyInternal(inProperty, inOptions);
 }