Let’s say I want to create a script that would automatically find a reference to some (irrelevant) object. However, I would like the script to do that only once - when it was added on the object (via an editor).
Is there any method that I’m missing that is run in that script when it is first added on a game object?
I have tried using Validate
method, but it is run every time you change any property of the script. I could make a flag for that, but that would not be super-clean. Alternatively, I could make the same flag for Awake and go for ExecuteInEditMode
, but there are other complications related to that.