c# - How to make a image clickable in unity 2d 4.3 -
i developing 2d game in unity 4.3 want know how can make image clickable using c#.for example don't want use button on game want different images when user click 1 of them happens.like 'setting' image setting option appears.please tell me how this.
thank you
there 1 or more way take sprite gameobject , click through script on it,or can through gui means ongui() method,make texture variable public , pass desried image through inspector panel , draw image in ongui(),like
public class exampleclass : monobehaviour { public texture btntexture; void ongui() { if (!btntexture) { debug.logerror("please assign texture on inspector"); return; } if (gui.button(new rect(10, 10, 50, 50), btntexture),guistyle.none) debug.log("clicked button image"); //pass guistyle none behaves image not button. } }
Comments
Post a Comment