c# - Unity - Event.current in Editor Window not updating -
so i'm working on custom editor window , trying when user has clicked left mouse button. problem i'm having whenever click on gui element have placed, in case editorgui.foldout element, event.current doesn't updated. when try check if user clicking left mouse button nothing whenever should be. if i'm not clicking in area detects it!
so question doing wrong here? i'm collecting event.current @ first line of void ongui() , no else. i'll add in code snippets in finding solution!
where call event.current:
void ongui() { event currentevent = event.current; ... }
when i'm trying access event.current:
void ongui() { ... rect baselabelrect = new rect(); baselabelrect.x = 0; baselabelrect.y = 21; baselabelrect.width = this.position.width; baselabelrect.height = 16; if (selected) editorgui.drawrect(baselabelrect, selecteditemcolor); editorgui.indentlevel = 1; gui.contentcolor = color.black; gui.backgroundcolor = color.grey; itemlistfoldout[0] = editorgui.foldout(baselabelrect, itemlistfoldout[0], "fouldout test"); gui.contentcolor = origcontentcolor; gui.backgroundcolor = origbackgroundcolor; if (currentevent.button == 0 && currentevent.ismouse) { debug.log("left mouse button clicked"); if (baselabelrect.contains(currentevent.mouseposition)) { selected = true; debug.log("rect clicked"); } else selected = false; } }
this i'm having troubles. whenever click on area editorgui.foldout @ should detected , setup selected. doesn't seem update event.current whenever click in foldout's area. update if click anywhere else in editor window.
if have idea why happening love hear ideas! , appreciated!
another way detect clicking left mouse button input.getkeydown function within update function, so:
void update(){ if (input.getkeydown(keycode.mouse0)){ debug.log("left mouse button clicked."); } }
i hope helpful!
Comments
Post a Comment