简体   繁体   English

过渡到“游戏结束”场景后按钮不起作用

[英]Button not working after transitioning to "game over" scene

I'm trying to implement a restart button after the player loses but am having trouble.我正在尝试在玩家输了但遇到麻烦后实施重启按钮。 As it stands, the player loses, an animation occurs to fade out of the game and fade in to the next scene where a canvas is presented.就目前而言,玩家输了,出现 animation 淡出游戏并淡入出现 canvas 的下一个场景。 The canvas has a text box with the words "Game Over" in it and a button below it for restarting. canvas 有一个文本框,其中包含“Game Over”字样,下方有一个用于重新启动的按钮。

When pushing restart, nothing happens.按下重启时,没有任何反应。 Nothing happens to the color when hovering over or pressing the button.将鼠标悬停在按钮上或按下按钮时,颜色不会发生任何变化。 I think it has something to do with the fact that the scene has the scene changer object in order for the scene to fade in and out smoothly.我认为这与场景具有场景变换器object以便场景顺利淡入淡出有关。 I have tried fiddling with the raycast target box, among other things.我试过摆弄光线投射目标框等。 Is there some sort of interference that happens with animations and buttons?动画和按钮是否会发生某种干扰? Perhaps a layering issue?也许是分层问题? Thanks!谢谢!

Solution 1: Are you using an actual Button?解决方案 1:您使用的是实际的 Button 吗? It seems that you have said "raycast" on your button.看来您已经在按钮上说了“光线投射”。

Solution 2: Make sure the UI is centered over top of your text box this way you properly select it!解决方案 2:确保 UI 在文本框上方居中,这样您就可以正确地 select 了!

Solution 3: Place a script on something that may be blocking the button if you are using "raycast" and do gameObject.SetActive(false);解决方案 3:如果您使用“raycast”并执行 gameObject.SetActive(false);,请将脚本放在可能会阻挡按钮的东西上

These are all the methods I could think of, If you need any help.这些是我能想到的所有方法,如果您需要任何帮助。 please feel free to add a comment.请随时添加评论。 Kind Regards ~~ SB亲切的问候~~ SB

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

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