c# - Mimicking custom function -


i have defined custom functions in following script , attached gameobject. want declare function onreticleenter() mimick onpointerenter(). possible? want because want access function onreticleenter() in inspector can define multiple actions eventtrigger's point enter, exit etc. possible make function onreticleenter() behave onpointerenter() programmatically?

using unityengine; using system.collections; public class myobject : monobehaviour {         // custom reticle events     public gameobject gobj;     public void onreticleenter()     {         gobj.setactive(true);     }     public void onreticleexit()     {         gobj.setactive(false);     }     public void onreticlehover()     {         gobj.setactive(true);     } } 

you need inherit interfaces pointerenter , pointerexit events in class able implement them. code might :

using unityengine; using unityengine.eventsystems; using system.collections;  public class myobject : monobehaviour,ipointerenterhandler, ipointerexithandler {     // custom reticle events     public gameobject gobj;     public void onpointerenter(pointereventdata eventdata){         gobj.setactive(true);     }    public void onpointerexit(pointereventdata eventdata){         gobj.setactive(false);     }  } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -