[英]Why is my input in the Unity editor window working perfectly but not at all in the game build?
I have a pretty simple script:我有一个非常简单的脚本:
void Start()
{
}
void Update()
{
if (Input.GetKeyDown("return")){
play();
}
}
void play()
{
anim.SetTrigger("playbutton");
}
It works wonders in the editor window, but when I build and run, absolutely nothing happens.它在编辑器 window 中创造了奇迹,但是当我构建和运行时,绝对没有任何反应。 It loads the scene just fine, but the button inputs don't seem to be getting through.
它可以很好地加载场景,但按钮输入似乎没有通过。
UPDATE: I tried several different buttons, but those didn't work.更新:我尝试了几个不同的按钮,但这些都不起作用。 I did try putting the anim.SetTrigger line in the Start function, and it didn't work either, which means that this is a problem with the animator/script, not the input.
我确实尝试将 anim.SetTrigger 行放在 Start function 中,但它也不起作用,这意味着这是动画师/脚本的问题,而不是输入的问题。
the script seems simple and fine, i suggest that u try the same script in an empty project to see if it works or not if it dose work try to apply the script on an other game object and run.该脚本看起来简单而精细,我建议您在一个空项目中尝试相同的脚本,看看它是否有效,如果它有效,请尝试将该脚本应用于其他游戏 object 并运行。 lets say it didn't work u can try this instead "if (Input.GetKeyDown(KeyCode.Return)" or try to use an other key
假设它不起作用,您可以尝试使用“if (Input.GetKeyDown(KeyCode.Return)”或尝试使用其他键
I'VE FOUND IT.我找到了。 The animation component in the object in question was set to cull completely, not always animate.
有问题的 object 中的 animation 组件被设置为完全剔除,并不总是动画。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.