DisplayInsteadInPlaymodeAttribute

class DisplayInsteadInPlaymodeAttribute : PropertyAttribute

This attribute is used to display a replacement property during editor play mode. This is used to prevent editing of serialized values in ScriptableObjects in play mode, which would be persistent.

  public class Example : ScriptableObject, ISerializationCallbackReceiver
{
  [DisplayInsteadInPlaymode(nameof(value))]
  [SerializeField]
  private SomeType originalValue;

  public SomeType value;

  void ISerializationCallbackReceiver.OnAfterDeserialize()
  {
      value = originalValue;
  }

  void ISerializationCallbackReceiver.OnAfterDeserialize()
  {
  }
}
  

Properties

replacementName : string

tooltip : string

A tooltip to display alongside the general tooltip for this attribute. Use only on ScriptableObjects, use [Tooltip] in MonoBehaviours.

Methods

DisplayInsteadInPlaymodeAttribute(string replacementName)

(Constructor)