Exemple #1
0
        // Draw the property inside the given rect
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // First get the attribute since it contains the range for the slider
            if (attribute is DefaultObjectAttribute)
            {
                DefaultObjectAttribute range = (DefaultObjectAttribute)attribute;

                // Now draw the property as a Slider or an IntSlider based on whether it's a float or integer.
                if (property.propertyType == SerializedPropertyType.ObjectReference)
                {
                    DisplayCheckboxAndControl(property, range, position, SetToNull, DisplayObjectField, ref isEnabled, ref objectValue);
                }
                else
                {
                    EditorGUI.LabelField(position, label.text, "Use DefaultObject with objects.");
                }
            }
        }
Exemple #2
0
 static void SetToNull(SerializedProperty property, DefaultObjectAttribute range)
 {
     property.objectReferenceValue = null;
 }
Exemple #3
0
 static void DisplayObjectField(SerializedProperty property, DefaultObjectAttribute range, Rect position, ref Object value)
 {
     value = EditorGUI.ObjectField(position, value, property.objectReferenceValue.GetType(), true);
 }