I need help making my button navigate to a different gameobject or scene in Unity. Can someone help me?

huangapple go评论74阅读模式
英文:

I need help making my button navigate to a different gameobject or scene in Unity. Can someone help me?

问题

有人可以帮助我吗?我一直在尝试让我的按钮在Unity中工作!我看过多个YouTube视频,但都不适用于我!

*我希望我的播放按钮显示一个游戏对象并隐藏当前的游戏对象。

我的工作区图片:-

我看过许多教程,也有很多结果:

  • 我正在使用Visual Studio Code,但场景管理未被识别。
  • 即使我的设置已经设置为在选择按钮时突出显示,也没有结果。
  • 我尝试过GameObject,但它根本不起作用,我没有收到错误消息,只是没有证据表明我的按钮实际上被按下了!
  • 我移除了背景并将按钮移到前面,以查看是否被覆盖,但仍然没有证据表明我的按钮实际上被按下了。
英文:

Can someone help me? I have been trying to make my buttons work in Unity! I have watched multiple youtube videos and none of them work for me!

*I want my play button to show a gameobject and hide the current gameobject.

Image of my workspace : -

<img src="https://i.stack.imgur.com/gfEuG.jpg">

I have watched many tutorials, and had many results:

  • I am using visual studio code yet scene management is not recognized.
  • Even when my settings are set to highlight the button when selected, there is no result.
  • I have tried gameobject but its just not working, im not recieving an error there is just no proof my button is actually being pressed!
  • I removed my background and pulled the button to the front, to see if it was being covered, but It still had no proof my button is actually being pressed.

答案1

得分: 0

首先,请确保您已将Unity首选项中的"External Tools"设置为Visual Studio Code,并在Unity Package Manager中安装了Visual Studio Code Package。

我希望您有一个UI管理脚本,即使没有也没有问题。在OnClick()中,请确保已引用了GameObject并选择了SetActive()。

然后,单击+图标并在该引用中添加另一个字段[拖放]当前按钮并选择SetActive(),以显示要更改的状态的复选框。请确保您设置它正确。

我希望这能有所帮助。

英文:

First of All just make sure you have set the External Tools in Unity Preferences to Visual Studio Code and you have install the Visual Studio Code Package in Unity Package Manager.

I hope you have an UI Managing Script or even not that's not a Problem. In OnClick() make sure you have referenced the GameObject and Selected the SetActive(),

and Click + icon and add another field in that Reference[Drag and Drop] the current button to and Select SetActive() that checkbox present shows the state to be changed into. Please Make Sure you are setting it Correctly.

I need help making my button navigate to a different gameobject or scene in Unity. Can someone help me?

I hope this helps.

huangapple
  • 本文由 发表于 2023年1月9日 11:49:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/75053017.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定