1
\$\begingroup\$

I have made a script with several properties and enums that I attached to an empty game object. I am making changes to the values within the inspector, since they a public. How can I get the scene window to recognize these changes as they occur?

\$\endgroup\$
1
\$\begingroup\$

If we're talking solely about changes in the Inspector, you can use the OnValidate() MonoBehaviour message.

This is called in-Editor-only (including in & out of play mode) whenever an Inspector property in the script is changed.

You can use this to validate and adjust the new settings, update other object properties to reflect them, or fire off other reaction scripts & events.

This will not be called in a standalone build of the game, so you can use setter methods instead to react to runtime changes caused by other scripts in your game.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.