- Home /
Probobly easy fix , int dosnt change issue.
I want to change the int "select" in the funktions chosemap with buttons. that works and the debug works correctly. But when I press space the int I had firts allways gets debbugged instead of the updated int(selected).
example:
I press button 1, the chosemap 1 runs . i Get a debug saying "1". Then I press space and 1 is debugd. all correct. Then i press 2 and the chosemap 2 runs. I get a debug saying "2". But then I expect to see the number "2" to be debuged when i press space. but still 1 is being debugged when i press space. It is like the first time i press a button select gets locked to that first value somehow.
apreaciate any help Thanks.
public int select = 0;
private void Start()
{
Instantiate(smm);
}
public void chosemap1()
{
select = 1;
Debug.Log(select);
}
public void chosemap2()
{
select = 2;
Debug.Log(select);
}
public void chosemap3()
{
select = 3;
Debug.Log(select);
}
void Update()
{
if (Input.GetKeyDown("space"))
{
Debug.Log(select);
}
}
Answer by Pinkuboxu · Jun 19, 2018 at 07:49 PM
I think what is happening is that your first UI button is the default control. Space is actually pressing the default UI button, so change your debug key to something else, like GetKeyDown("A") or disable the default key press of your Button. It should be under Navigation on the Button Script.
no, the space button will debug.log 3 if i changed the int select to 3 first. I do not think that the space activates button1 if that is what you mean.
thanks tho
Your answer
Follow this Question
Related Questions
Button is unable to grab functions with two parameters? 0 Answers
Missing function in button on click 1 Answer
touch buttons function OnGUI issue 1 Answer
Add EditorUI elements when a button is pressed 0 Answers
Pass a function(float) as variable 2 Answers