Relative Content

Tag Archive for c#unity-game-engineserializationproperties

Unity: Calling Property Setter when Serialized Backing Field is Changed

I have a script that executes in both Edit and Play mode. It contains several properties with setters that do important stuff to keep the GameObject’s data up-to-date. So I can edit the properties’ values, many of them have backing fields with the SerializeField attribute. I would like to know if there are any efficient ways to make it so that whenever one of the backing fields are edited via the Inspector, the setter of the corresponding property is called to keep the GameObject updated and to enable real-time previewing of the result.