团结5:我如何检测上的自定义按钮和对象的触摸自定义、按钮、团结、对象

2023-09-07 00:05:45 作者:病变系少女

我试图让Android和iPhone上的游戏,如果玩家点击了一个3D的胸部,他将收到一些项目。我曾经做过的项目捐赠,但我不能正确地检测触摸。此外,它必须有多个触摸的支持,因此付款人可以保持pressing移动按钮,在打开的胸口。

I am trying to make a game for Android and iPhone where if the player clicks a 3d chest, he will recieve some items. I have done the item giving, but I cannot detect a touch properly. Also it has to have a support for multiple touches, so the payer can keep pressing the move button, while opening the chest.

我没有这样做既不按钮触摸检测,也没有对物体的触摸检测?

I have not done neither the detect on button touch, nor the detect on object touch?

可他们每个人都有自己的脚本,或者他们将在一个脚本if语句?

Can each of them have their own script or will they be all in one script with if statements?

推荐答案

您可以实现 IPointerClickHandler 界面,你的胸部对象的脚本这样的事情:

You can implement IPointerClickHandler interface to your chest object script something like that :

class ChestObject : MonoBehaviour, IPointerClickHandler
{
    // Your other functions ...

    void OnPointerClick(PointerEventData eventData)
    {
        //The program will run this function when you click the chest
    }
}

取决于你的需要,你还可以实现 IPointerDownHandler IPointerUpHandler IDragHandler IDropHandler 等,这些接口来与新的UI系统,他们是非常有用的。

Depends on your needs, you can also implement IPointerDownHandler, IPointerUpHandler, IDragHandler, IDropHandler etc.. These interfaces came with the new UI system and they are quite useful.

 
精彩推荐
图片推荐