- Home /
calculate things... and display in inspector
so, i have a script (js) like that:
var a; var b;
var c; c = a + b;
after i attach this script to an object, i wonder if there is any way in that if i change the values of a or b, to see the new "c" in inspector... some kind of input text for a and b and dynamic text for c.
Answer by Tetrad · Jun 09, 2010 at 10:14 PM
Try playing around with ExecuteInEditMode.
So like this:
@script ExecuteInEditMode()
var a; var b; var c;
void Update() { c = a + b; }
(I haven't tested this.)
Answer by Ricardo · Jun 09, 2010 at 10:10 PM
As unity does not display properties with getters/setters, your best bet would be writing a custom inspector.
Answer by hyper · Jun 10, 2010 at 01:01 AM
yep, this is working! thanks!
i just added the var types for a,b,c, i get some errors if not... here is the javascript version:
@script ExecuteInEditMode()
var a:float; var b:float; var c:float;
function Update() { c = a + b; }
Your answer
Follow this Question
Related Questions
Unity Editor - Class variable value contrain 4 Answers
Drawing a custom variable in the inspector y position bugs selection 0 Answers
Making a minor change to Default inspector? 1 Answer
OnInspectorGUI changes reset when played in editor or building 2 Answers
Custom inspector, show string instead of component type 0 Answers