/// <summary> /// Draw a serialized property field associated with another property ; /// when setting field value, associated property will be set automatically. /// Usefull for clamping value or calling event on inspector edit. /// </summary> /// <param name="_property">Serialized property to edit.</param> /// <param name="_label">Displayed label.</param> /// <param name="_propertyName">Name of the associated property (must be in the same script as the property field).</param> public static void PropertyField(SerializedProperty _property, GUIContent _label, string _propertyName) { // Get rect Rect _position = EditorGUILayout.GetControlRect(true, EditorGUIUtility.singleLineHeight); // Draw field EditorGUIEnhanced.PropertyField(_position, _property, _label, _propertyName); }
/*************************** ******* METHODS ******* **************************/ // Make your own IMGUI based GUI for the property public override void OnGUI(Rect _position, SerializedProperty _property, GUIContent _label) { // Get linked property name PropertyFieldAttribute _attribute = (PropertyFieldAttribute)attribute; string _propertyName = string.IsNullOrEmpty(_attribute.PropertyName) ? (char.ToUpper(_property.name[0]) + _property.name.Substring(1)) : _attribute.PropertyName; // Draw field EditorGUIEnhanced.PropertyField(_position, _property, _label, _propertyName); }