An attribute for Unity fields that visually marks them as "obsolete" in the Unity Editor.
- Import the
ObsoleteUnityField
namespace into a C# file. - Put
[ObsoleteUnityField]
on any field.
using UnityEngine;
using ObsoleteUnityField;
public class MyBehaviour : MonoBehaviour
{
[SerializeField, ObsoleteUnityField("Use the min threshold field."), Obsolete]
private float _threshold = 0.15f;
[SerializeField]
private float _minThreshold = 0.5f;
}
- The constructor can take an optional
string
message which gets appended to the front of the field's tooltip (if there is one). See the above example. - The constructor can take another optional
bool
value to denote whether or not the field is editable.
[ObsoleteUnityField, SerializeField]
private int _obsoleteField1 = 10;
[ObsoleteUnityField("Don't use this field.")
private int _obsoleteField2 = 10;
[ObsoleteUnityField(false)]
private int _obsoleteField3 = 10;
[ObsoleteUnityField("This field has been made obsolete.", false)]
private int _obsoleteField4 = 10;
- Not a replacement for
[Obsolete]
, but useful as a parallel attribute.