- Home /
Check GUI toggle button with the M keyboar Key
So i have this toggle button to show my window as a click on it with the mouse my question is,could it be possible to assign the M key to check the toggle button to show my window ?
this is the script i have , helpe me please
using UnityEngine;
using System.Collections;
public class SkinTest : MonoBehaviour
{
public GUISkin thisAmigaGUISkin;
private Vector2 scrollPosition = Vector2.zero;
public bool doWindow0 = true;
void DoWindow0(int windowID)
{
}
void OnGUI() {
GUI.Box(new Rect(10,8,145,35), "Menu Del Santuario\nOn/Off");
doWindow0 = GUI.Toggle(new Rect(10, 15, 145, 30), doWindow0, "");
if (doWindow0)
GUI.Window(0, new Rect(10, 44, 700, 500), DoWindow0, "Basic Window");
}
}
toggle.jpg
(18.6 kB)
Comment
Answer by robertbu · May 30, 2013 at 04:13 AM
Adding this should work:
void Update() {
if (Input.GetKeyUp(KeyCode.M))
doWindow0 = !doWindow0;
}
Like this:
using UnityEngine;
using System.Collections;
public class SkinTest : $$anonymous$$onoBehaviour {
public GUISkin thisAmigaGUISkin;
private Vector2 scrollPosition = Vector2.zero;
public bool doWindow0 = true;
void Update() {
if (Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.$$anonymous$$))
doWindow0 = !doWindow0;
}
void DoWindow0(int windowID) {
}
void OnGUI() {
GUI.Box(new Rect(10,8,145,35), "$$anonymous$$enu Del Santuario\nOn/Off");
doWindow0 = GUI.Toggle(new Rect(10, 15, 145, 30), doWindow0, "");
if (doWindow0)
GUI.Window(0, new Rect(10, 44, 700, 500), DoWindow0, "Basic Window");
}
}
Dont forget to accept the answer if this answer solved your question.
Your answer
![](https://koobas.hobune.stream/wayback/20220613103159im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Assign a hotkey to a GUI button? 3 Answers
Bunny Hop control 1 Answer
How to reset the state of other buttons when clicking on one of them 0 Answers