- Home /
getButton always return true
When I call getButton with same button in input module in code. It's always return true, even i didnt click that button and i already disable all interactable ui element. If I change to different button that not same button in input module,it's work fine.
so if i want to getButton the same button in input module. What should i do.
edit add some code
if(Input.GetButton("Ok") && !submitClicked){
submitClicked = true;
foreach(GameObject obj in target){
obj.GetComponent<BaseCharacterObject>().Selected = false;
}
action.Target = target.ToList();
uiState = UIStateMachine.EndUIState;
submitClicked = false;
}
Button "Ok" is the same as Submit button in Standalone Input module When i run ,Input.GetButton("Ok") is always return true even i didnt press it
I feel like i know the problem, but still dont know how to fix it. before the process come to this if expression.I have to press O$$anonymous$$ 1time. because of this, GetButton("Ok") is still true when the process come to expression and run the code at lest 1time.
I think i have to wait till GetButtonUp is true and do this (maybe).
Answer by Qasem2014 · Jan 04, 2015 at 06:38 PM
test your input :
if(Input.GetButton("Ok")) { print("OK"); }
so if it works good , submitClicked variable coused problem