Hi!
Really quick question, that I think I know the answer to. I’m coming from Unreal, and there, they have a construction script that is run in edit mode as well as before play begins. It basically allowed you to preview random changes to actors, or if you had a variable define physical attributes of a gameobject, you would see the changes live in edit mode.
I’m just wondering if there’s a way to do this in Unity?
For example, say I have a public float m_radius which I want to define the radius of a collision sphere. In Start() I could say collider.radius = m_radius, but that happens when I hit play. Is there a way to make that change reflected in edit mode?
Thanks!
Best,
Peter
Maybe this is what you need
I’m not understanding.
You want that when the game is NOT in play, that the value shows as the value that would be set when play is pressed?
Or are you saying that when you press play, you want the editor to display the value as it is at that moment?
If it’s the latter, that’s exactly how it works by default.
If it’s the prior… why would you want that?
I think he wants something like how when you change a colliders radius in the editor, you see the change right away.
Or another example, you are creating a randomly generated map with a seed, and when you change the seed in edit mode, the map on screen updates without needing to press play.
Or more simply, the transform component has a position vector that when you change, the object moves in edit mode. If someone was to have a custom component with a public vector3 called startPosition, how can they have their object move to that position in edit mode?
He can use the executeineditmode, or maybe create a custom editor.