简体   繁体   English

在 Unity 中将 Sprite 附加到 3D 按钮

[英]Attach Sprite to button in 3D in Unity

I have a button which activates a method and I want some sprites to be activated when I click on the button (arrows that surround the button).我有一个激活方法的按钮,我希望在单击按钮时激活一些精灵(按钮周围的箭头)。 Now I tried to do it manually but since it is 3D it doesn't follow the button.现在我尝试手动进行,但由于它是 3D 的,它不跟随按钮。 When I add a Sprite Renderer I am not able to move the sprites.当我添加精灵渲染器时,我无法移动精灵。 Do you have any idea how I can do this?你知道我该怎么做吗?

One possible solution might be to create a new Canvas for your button and setting it to world space.一种可能的解决方案可能是为您的按钮创建一个新的 Canvas 并将其设置为世界空间。 You probably have to set the width and height to something much smaller.您可能必须将宽度和高度设置为更小的值。 And Text sizes have to be reduced significantly as well.并且文本大小也必须显着减小。 But other interactions like clicking should work just like on a normal screen space canvas.但是像点击这样的其他交互应该像在正常的屏幕空间画布上一样工作。

在此处输入图像描述

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

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