I have components which change the state of a GameObject when enabled/disabled.
For example:
- I attach a Frozen component to a GameObject
- When the component is enabled it will change the sprite of the GameObject to which it is attached to a frozen variant (the component also handles all the logic of the GameObject in a Frozen state)
- When the component is disabled the GameObject will revert back to a standard state and its sprite revert also
I would like these changes reflected in the Editor if possible. I read about Unity - Scripting API: ExecuteAlways which may help here but it should only be applied to certain methods in the script OnEnable/OnDisable (where the sprites are set) and not all of it.
I’m also open to changing my approach as I’m not entirely happy with changing the sprite on a component basis. The art style does not lend itself to a layered approach (drawing the frozen sprite from the Frozen Component, when enabled, on top of the standard GameObject sprite) as each state is represented with a unique sprite. The issue with a unique sprite per state is that I would have to decide which state would have precedence when multiple states (Components are enabled).
Would appreciate any thoughts, advice, or pointing in the direction of documents in this area.