- Home /
Question by
SmokingAces207 · Jul 24, 2015 at 03:30 PM ·
c#inputongui
How to get User Input to Work in OnGUI and Update Functions Please help!
Ok so I have been trying to fix this for 2 days, thinking my logic somewhere was wrong. But after a little test statement I realized its the way I'm taking user input. It is happening too fast from what I can see. If someone could explain a better way to take the input so that the menu is not skipping to the end when I hold down the Z key and then when I release it, it skips to the start of dialogue again.... Any suggestions? thanks :)
Where I am changing the user input dialogue window based on the user input of Z is the key part of this. The rest seems to work fine.
Update Function.
void Update () {
if (Input.GetKeyDown (KeyCode.X)) {
moveWindowDisabled = true;
} else if (Input.GetKeyUp (KeyCode.X)) {
moveWindowDisabled = false;
}
if (Input.GetKey (KeyCode.Z)) {
dialogueWindowContinue = true;
} else if (!Input.GetKey (KeyCode.Z)) {
dialogueWindowContinue = false;
}
}
OnGUI Function:
void OnGUI () {
if (moveWindowDisabled && moveWindow.gameObject.activeInHierarchy) {
moveWindow.gameObject.SetActive(false);
}
if (TurnBasedCombatStateMachine.playersChoice && !dialogueWindow.gameObject.activeInHierarchy) {
dialogueWindow.gameObject.SetActive (false);
} else if (!TurnBasedCombatStateMachine.playersChoice) {
dialogueWindow.gameObject.SetActive (true);
}
dialogueWindowText.text = "It was a Critical Hit ...";
if (dialogueWindowContinue){
dialogueWindowText.text = "Status Effects and Damage Calculations next....";
if (dialogueWindowContinue){
dialogueWindowText.text = "Testing testing 123......";
}
}
/*if (BattleStateStart.playerStartedFirst) {
PlayerFirstDialogue ();
} else if (!BattleStateStart.playerStartedFirst) {
EnemyFirstDialogue ();
}*/
}
Comment