Change display in editor (without starting the game)
Hello,
I would like to make changes to my game object to be displayed in the editor right away.
Example:
I have a path with several points. I would like to mark some of the points as "free to pass point" and some as "battle point".
"battle point" or "event point" configured by flag "isBattle" - if "isBattle" true - it's battle point.
Based on the flag points will have different sprites - for battle, it will be "skull" and for free it'll be just "green dot".
The problem is - in case I change the flag, in the editor sprite won't change, it requires to run the game to apply changes.
I placed this logic in Start. I've also tried to place it OnValidate, but have warnings from Unity.
Could you suggest a proper way to enable changes in the editor right away?
The code:
private void Start()
{
_spriteRenderer = GetComponent<SpriteRenderer>();
var spriteToDraw = triggerBattle ? battleSprite : clearedSprite;
_spriteRenderer.sprite = spriteToDraw;
}
Your answer
Follow this Question
Related Questions
Sprite.Create created sprite during editor time becomes null during runtime 1 Answer
Auto Increase SpriteRenderer Order in Layer? 0 Answers
Sprite change on click 0 Answers
Problems changing a sprite from code(C#) 0 Answers
Solution for a Tiles Instantiated Object not appearing on Tile Palette? 0 Answers