简体   繁体   English

使用NGUI / Unity3D调用触摸功能吗?

[英]Call a touch function using NGUI/Unity3D?

I have a game that is using GUITextures for buttons but it isn't working on different resoltutions. 我有一个使用GUITextures作为按钮的游戏,但不适用于不同的分辨率。 So I was told NGUI would do it very easily. 因此,我被告知NGUI会非常轻松地做到这一点。 But I already have the code written for the GUITexture buttons. 但是我已经为GUITexture按钮编写了代码。

How do I do it for NGUI buttons using the same textures? 对于使用相同纹理的NGUI按钮,我该如何做? I've searched everywhere and can not find any answers....the NGUI forums are not much help. 我到处搜索,找不到任何答案。...NGUI论坛没有太大帮助。

Your Gameobject should have any type of collider component then in script do the following: 您的Gameobject应该具有任何类型的对撞机组件,然后在脚本中执行以下操作:

//Use UIEventListener to bind your gameobject with your desired method 

public GameObject YOUR_BUTTON_GAMEOBJECT;

UIEventListener.Get(YOUR_BUTTON_GAMEOBJECT).onClick += YOUR_METHOD_NAME;


//METHOD SIGNATURES 
void YOUR_METHOD_NAME(GameObject gameObject){
     //On Click Stuff
}

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM