void OnGUI() { if (toggle != null) //当前已经选中按钮 { string FunctionNow = toggle.name.ToString(); if (Input.anyKeyDown) { Event e = Event.current; if (e.isKey && e.keyCode != KeyCode.None) { GameObject btnText = GameObject.Find(FunctionNow + "Text"); if (!KeySetManager.isUsed(e.keyCode)) //当前按键未使用 { KeySetManager.setKey(FunctionNow, e.keyCode); btnText.GetComponent <Text>().text = e.keyCode.ToString(); } else //冲突 { //hintWindow.SetActive(true); //GameObject hintText = GameObject.Find("HintText"); string ConflictFunction = KeySetManager.getConflictKey(e.keyCode); Debug.Log(ConflictFunction); GameObject ConflictBtnText = GameObject.Find(ConflictFunction + "Text"); // hintText.GetComponent<Text>().text = "与功能" + ConflictFunction + "冲突,是否继续?"; KeySetManager.setKey(ConflictFunction, KeyCode.None); ConflictBtnText.GetComponent <Text>().text = "未设置"; KeySetManager.setKey(FunctionNow, e.keyCode); btnText.GetComponent <Text>().text = e.keyCode.ToString(); } } } } }