Hi guys
I want to write a script that when an object’s position changes in the SceneView , in the inspector we see changes .for example when i move the box on screen ,i’ll be able to view distance between box and other object in the inspector fields.
I have my “extend editor Script” but i can’t do the changes on it !
Thanks for help
You can add a float variable Distance in your script and the object you want to check the distance with.
You will update the Distance variable in the OnUpdate(). You calculate the distance with the static method Vector3.Distance( pos1, pos2).
Allow your script to be executed in editor more using this : Unity - Scripting API: ExecuteInEditMode
any idea ?
i need it .
can it be done ever ?
Variables in scripts and object transforms are updated in the inspector as is.
If you want to see the distance between your 2 objects, you need to calculate it in a script and store it in a Public variable.
To see the value in the inspector you should just select the object with the script attached.
Edit: Alternatively you can set it as a Private variable and right click the inspector tab and enter ‘debug mode’, then you will be able to see, but not change, the Private variables.