public class SomeComponent : MonoBehaviour {
[SerializeField] private int _someValue;
public int SomeValue
{
get { return _someValue; }
set
{
if (_someValue == value) return;
_someValue = value;
}
}
}
–
public override void OnInspectorGUI()
{
Target.SomeValue = EditorGUILayout.IntField("Some Value", Target.SomeValue);
}
Before play I can assign a value to SomeValue (which applies the value to _someValue). When hitting play the value resets to 0.
I set a breakpoint at the setter and it does not get set to 0, it is initiaized at 0.