- Home /
key remaping menu
i made a script scene where the player can replace the key bindings this is the script :
public Button changeUp;
public Text upText;
public bool lookforUp = false;
public void ChangeUp() { // this is put OnClick on the button "changeUp"
if (lookforUp == false)
{
lookforUp = true;
upText.text = "";
}
}
void Update () {
Up();}
void Up() {
if (lookforUp == true)
{
if (Input.GetKey("mouse 0"))
{
upText.text = "mouse 0";
Inputs.inputs.up = upText.text;
}
else if (Input.GetKey("left shift"))
{
upText.text = "left shift";
lookforUp = false;
Inputs.inputs.down = upText.text;
}
else if (Input.GetKey("escape"))
{
upText.text = "escape";
lookforUp = false;
Inputs.inputs.up = upText.text;
}
else if (Input.GetKey("space"))
{
upText.text = "space";
lookforUp = false;
Inputs.inputs.up = upText.text;
}
else if (Input.GetKey("enter"))
{
upText.text = "enter";
lookforUp = false;
Inputs.inputs.up = upText.text;
}
else if (Input.GetKey("mouse 1"))
{
lookforUp = false;
upText.text = "mouse 1";
Inputs.inputs.up = upText.text;
}
else if (Input.GetKey("mouse 2"))
{
lookforUp = false;
upText.text = "mouse 2";
Inputs.inputs.up = upText.text;
}
else if (Input.anyKeyDown)
{
Debug.Log(Input.inputString);
lookforUp = false;
string temp = Input.inputString.Substring(0, 1);
upText.text = temp;
Inputs.inputs.up = upText.text;
}
}
}
and that gets repeated with 18 more buttons
the problem is that when i press on multiple buttons, after pressing a key all the pressed keys' text get changed to the same key
(if on Input.GetKey("mouse 0") i put looklookforUp = false changes very fast from "mouse 0" to "")
Have you tried debugging your script and setting break points to watch when your variables change?
Your answer
Follow this Question
Related Questions
How do I enable keys/buttons on input manager properly on unity3d 0 Answers
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Gui list and color 0 Answers
Is there a way to temporarily disable an inputmanager axis through script? 1 Answer
Touch inputs on a Desktop type device 2 Answers