From b898318475d3955579a6cf07ad11238cc9ec3acc Mon Sep 17 00:00:00 2001 From: "guzhu@fairygui.com" Date: Wed, 29 Jul 2020 17:34:12 +0800 Subject: [PATCH] Try fix command key status in windows --- Assets/Scripts/Event/InputEvent.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Event/InputEvent.cs b/Assets/Scripts/Event/InputEvent.cs index 78e0c69b..236c20a9 100644 --- a/Assets/Scripts/Event/InputEvent.cs +++ b/Assets/Scripts/Event/InputEvent.cs @@ -94,8 +94,7 @@ public bool ctrlOrCmd { get { - return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl) - || Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand); + return ctrl || command; } } @@ -104,7 +103,7 @@ public bool ctrlOrCmd /// public bool ctrl { - get + get { return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl); } @@ -139,7 +138,11 @@ public bool command { get { - return Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand); + //In win, as long as the win key and other keys are pressed at the same time, the getKey will continue to return true. So it can only be shielded. + if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.OSXEditor) + return Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.RightCommand); + else + return false; } } }