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(); } } } } }
void Start() { foreach (KeyValuePair <string, KeyCode> kvp in KeySetManager.getKeySetting()) { GameObject text = GameObject.Find(kvp.Key + "Text"); text.GetComponent <Text>().text = kvp.Value.ToString(); } }
private void Awake() { if (main == null) { main = this; } else if (main != this) { //Destroy(gameObject); } KeySetManager.InitializeDictionary(); }
// Update is called once per frame void Update() { if (KeySetManager.GetKeyDown("Menu")) { Cursor.visible = !Cursor.visible; } newpos = Input.mousePosition; if (oldpos.z > -500) { diff = newpos - oldpos; } oldpos = newpos; r.anchoredPosition = new Vector2(newpos.x, newpos.y); switch (switchStatus) { case 0: { float mouseSpeed = diff.magnitude; mouseSpeed = (mouseSpeed * currentType.moveThreshold - 3f * currentType.recoverThreshold) / 170f; currSpeed = Mathf.Clamp(currSpeed + mouseSpeed, 0f, 1f); if (currentType.enabledMovement) { int i = 0; foreach (CursorSprite csp in currentType.cursorSprites) { if (csp.cursorStatus.Length > 0) { setCursor(csp, csp.cursorStatus[0], currSpeed); } CursorStatus tmp = new CursorStatus(); tmp.scale = csp.sprite.transform.localScale.x; tmp.alpha = csp.sprite.GetComponent <SpriteRenderer>().material.color.a; tmp.rotation = csp.sprite.transform.localEulerAngles.z; switchStartStatus[i] = tmp; i++; } } // 切换光标 // if (Input.GetKeyDown(KeyCode.Z)) { // switchType(cursor_test); // } // if (Input.GetKeyDown(KeyCode.C)) { // switchType(cursor_aim); // } } break; case 1: { switchTimeSec++; float f = Mathf.Clamp((float)switchTimeSec * Time.deltaTime / switchTime, 0f, 1f); f = Easing.EaseIn(f, EasingType.Quartic); for (int i = 0; i < currentType.cursorSprites.Length; i++) { setCursor(currentType.cursorSprites[i], switchStartStatus[i], switchTo, f); } if (switchTimeSec > (float)switchTime / Time.deltaTime) { switchStatus = 2; switchTimeSec = 0; setCursorTypeActive(currentType, false); switchTo.rotation = -switchTo.rotation; currentType = nextType; } } break; case 2: { switchTimeSec++; float f = Mathf.Clamp((float)switchTimeSec * Time.deltaTime / switchTime, 0f, 1f); f = Easing.EaseOut(f, EasingType.Quartic); for (int i = 0; i < currentType.cursorSprites.Length; i++) { setCursor(currentType.cursorSprites[i], switchTo, currentType.cursorSprites[i].initStatus, f); } if (switchTimeSec > (float)switchTime / Time.deltaTime) { switchStatus = 0; switchTimeSec = 0; switchTo.rotation = -switchTo.rotation; nextType = null; } } break; } //Input.mousePosition }