- Home /
Question by
Nova-1504 · Oct 13, 2016 at 08:18 PM ·
inputbuildscene-loadinggetkeydown
Input not working in-build.
#pragma strict
import UnityEngine.SceneManagement;
if(Input.GetKeyDown(KeyCode.Alpha1)||Input.GetKeyDown(KeyCode.Keypad1)){
SceneManager.LoadScene(1);
}
if(Input.GetKeyDown(KeyCode.Alpha2)||Input.GetKeyDown(KeyCode.Keypad2)){
Application.Quit();
}
This doesn't do ANYTHING when I build the game to test it. Why though? The script should work.
Comment
Is that the whole script or is it just a small part of it?
It has to be inside the Update() function so that it's executed every frame.
function Update ()
{
if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Alpha1) || Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.$$anonymous$$eypad1)){
Scene$$anonymous$$anager.LoadScene(1);
}
if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Alpha2) || Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.$$anonymous$$eypad2)){
Application.Quit();
}
}