unity3d - Why is my Object not filled -


i trying create select object script in unity.

what should when hover on object colors red (and does) , when press "1" gameobject's targethighlighted filled object hovering on @ moment. in debug.log works fine, targethighlightedis filled.

when press "1" targethighlighted object still left empty. doesn't matter if press while hovering on object or away it.

my full code more extensive this. section of code contains problem, reduced this.

can explain me how come when press "1" the debug.log doesn't show targethighlighted or targetselected?

basically why mouseenter , mouseexit log right object, settarget function doesn't?

using unityengine; using system.collections;  public class targetselectionscript: monobehaviour {     // store current selected gameobject     gameobject targethighlighted;     renderer rend;     color initialcolor = color.white;     color selectedcolor = color.red;     public gamecontrollerscript gamecontroller;      void start() {      }      void update() {         if (input.getkeydown("1")) {             settarget();         }     }      void onmouseenter() {         selecttarget();     }      void onmouseexit() {         cleartarget();     }      void selecttarget() {              raycasthit hitinfo = new raycasthit();             physics.raycast(camera.main.screenpointtoray(input.mouseposition), out hitinfo);             targethighlighted = hitinfo.transform.gameobject;             rend = targethighlighted.getcomponent < renderer > ();             rend.material.color = selectedcolor;             debug.log("highlighted target: " + targethighlighted);      }      void cleartarget() {         debug.log(targethighlighted);     }      void settarget() {         debug.log(targethighlighted);     } } 

because no key registered under "1"

for reason, must resort using appropriate keycode,

if (getkeydown(keycode.alpha1))     settarget(); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -