- Home /
Update Values into Inspector
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
Answer by Cripple · Aug 30, 2012 at 04:50 PM
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 : http://docs.unity3d.com/Documentation/ScriptReference/ExecuteInEditMode.html
Answer by 3agle · Aug 30, 2012 at 04:50 PM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220613080337im_/https://answers.unity.com/themes/thub/images/avi.jpg)