Click or drag to resize
PropertyBackingFieldAttribute Class
A PropertyAttribute to specify that a serialized field is a backing field for a property. A serialized backing field decorated with this attribute will trigger its getter and setter when the user makes changes from the inspector.
Inheritance Hierarchy
SystemObject
  SystemAttribute
    PropertyAttribute
      CandlelightPropertyBackingFieldAttribute

Namespace: Candlelight
Assembly: Assembly-CSharp-firstpass (in Assembly-CSharp-firstpass.dll) Version: 0.0.0.0
Syntax
C#
public class PropertyBackingFieldAttribute : PropertyAttribute

The PropertyBackingFieldAttribute type exposes the following members.

Constructors
  NameDescription
Public methodPropertyBackingFieldAttribute
Initializes a new instance of the PropertyBackingFieldAttribute class that uses the default PropertyDrawer for the field type. This constructor assumes that the backing field name starts with "m_" or "_" and that the property name otherwise matches. For example, a field m_Character or _Character could refer to either a property Character { get; set; } or a pair of methods GetCharacter() and SetCharacter().
Public methodPropertyBackingFieldAttribute(String)
Initializes a new instance of the PropertyBackingFieldAttribute class that uses the default PropertyDrawer for the field type.
Public methodPropertyBackingFieldAttribute(Type, Object)
Initializes a new instance of the PropertyBackingFieldAttribute class that should use a custom PropertyDrawer associated with another PropertyAttribute to display the decorated field in the inspector. This constructor assumes that the backing field name starts with "m_" or "_" and that the property name otherwise matches. For example, a field m_Character or _Character could refer to either a property Character { get; set; } or a pair of methods GetCharacter() and SetCharacter().
Public methodPropertyBackingFieldAttribute(String, Type, Object)
Initializes a new instance of the PropertyBackingFieldAttribute class that should use a custom PropertyDrawer associated with another PropertyAttribute to display the decorated field in the inspector.
Top
Properties
  NameDescription
Public propertyOverrideAttribute
Gets an optional PropertyAttribute that specifies what PropertyDrawer should be used for the decorated field.
Public propertyPropertyName
Gets the name of the property for which the decorated field is a backing field.
Top
Remarks
In order to use this attribute, the property to which the field corresponds must implement both get and set methods (any access modifiers are okay). These methods can be implemented either as a property or as methods. For example, either of the following examples is valid:
public class MyComponent : UnityEngine.MonoBehaviour
{
    [UnityEngine.SerializeField, Candlelight.PropertyBackingField]
    private int m_MyInt = 0;

    public int MyInt
    {
        get { return m_MyInt; }
        set { m_MyInt = Mathf.Max(0, value); }
    }
}
public class MyComponent : UnityEngine.MonoBehaviour
{
    [UnityEngine.SerializeField, Candlelight.PropertyBackingField]
    private int m_MyInt = 0;

    public int GetMyInt()
    {
        return m_MyInt;
    }

    public void SetMyInt()
    {
        m_MyInt = Mathf.Max(0, value);
    }
}
The corresponding custom property drawer ensures to the best of its ability that the object is properly dirtied so it is compatible with undo/redo and prefab overrides.
See Also