英文:
Simple Question on Clicking Colliders in UI Layer
问题
这是一个非常简单的问题,但是我需要在我的游戏中点击2D高尔夫球杆的头部。它是一个带有2D多边形碰撞器的精灵,我只需要在碰撞器被按下时才起作用。射线投射在这种情况下是否有效?
提前感谢!
我尝试过使用一些代码,但没有成功,我在Unity方面有些生疏。
英文:
This is a very simple question but I need to click the head of a 2D golf club in my game. It's a sprite with a 2D polygon collider on it and I just need it to only work when the collider is pressed. Do raycasts work wit this still?
Thanks in advance!
I've tried using a few codes but to no avail, I'm quite rusty at Unity.
Here's the prop+enter image description here
答案1
得分: 1
不需要在UI精灵中添加碰撞器。在您的高尔夫球杆头部创建一个透明图像,然后添加组件"Button"并添加您的方法。这样使用更简单。
英文:
you don't have to add collider in ui spirte. create a transparent image on your golfclub head. then add component "Button" and add your method. its more simple to use.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论