/// <summary> /// Inject a Unity keyboard event into the WebView /// </summary> public void InjectKeyEvent(Event keyEvent) { UnityKeyEvent uevent = new UnityKeyEvent(); uevent.Type = keyEvent.type == EventType.KeyDown ? 1u : 0u; uevent.KeyCode = (uint)keyEvent.keyCode; uevent.Character = (uint)keyEvent.character; // Do not forward newline if (uevent.Character == 10) { return; } // encode modifiers uevent.Modifiers = 0; if (keyEvent.command) { uevent.Modifiers |= (uint)UnityKeyModifiers.CommandWin; } if (keyEvent.alt) { uevent.Modifiers |= (uint)UnityKeyModifiers.Alt; } if (keyEvent.control) { uevent.Modifiers |= (uint)UnityKeyModifiers.Control; } if (keyEvent.shift) { uevent.Modifiers |= (uint)UnityKeyModifiers.Shift; } if (keyEvent.numeric) { uevent.Modifiers |= (uint)UnityKeyModifiers.Numeric; } if (keyEvent.functionKey) { uevent.Modifiers |= (uint)UnityKeyModifiers.FunctionKey; } if (keyEvent.capsLock) { uevent.Modifiers |= (uint)UnityKeyModifiers.CapsLock; } UWKPlugin.UWK_InjectKeyEvent(ID, ref uevent); }
/// <summary> /// Process a Unity keyboard event /// </summary> public void ProcessKeyboard(Event keyEvent) { if (inputDisabled) { return; } UnityKeyEvent uevent = new UnityKeyEvent(); uevent.Type = keyEvent.type == EventType.KeyDown ? 1u : 0u; uevent.KeyCode = (uint)keyEvent.keyCode; uevent.Character = (uint)keyEvent.character; // encode modifiers uevent.Modifiers = 0; if (keyEvent.command) { uevent.Modifiers |= (uint)UnityKeyModifiers.CommandWin; } if (keyEvent.alt) { uevent.Modifiers |= (uint)UnityKeyModifiers.Alt; } if (keyEvent.control) { uevent.Modifiers |= (uint)UnityKeyModifiers.Control; } if (keyEvent.shift) { uevent.Modifiers |= (uint)UnityKeyModifiers.Shift; } if (keyEvent.numeric) { uevent.Modifiers |= (uint)UnityKeyModifiers.Numeric; } if (keyEvent.functionKey) { uevent.Modifiers |= (uint)UnityKeyModifiers.FunctionKey; } if (keyEvent.capsLock) { uevent.Modifiers |= (uint)UnityKeyModifiers.CapsLock; } UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent); }
/// <summary> /// Process a Unity keyboard event /// </summary> public void ProcessKeyboard(Event keyEvent) { if (inputDisabled) return; UnityKeyEvent uevent = new UnityKeyEvent(); uevent.Type = keyEvent.type == EventType.KeyDown ? 1u : 0u; uevent.KeyCode = (uint) keyEvent.keyCode; uevent.Character = (uint) keyEvent.character; if (uevent.Character == 10) return; // Fix mac deployment Unity key handling bug #if !UNITY_EDITOR #if UNITY_STANDALONE_OSX if (keyEvent.command && (keyEvent.keyCode == KeyCode.V || keyEvent.keyCode == KeyCode.A || keyEvent.keyCode == KeyCode.C)) { if (keyEvent.type != EventType.KeyDown) return; uevent.Type = 1u; uevent.KeyCode = (uint) keyEvent.keyCode; uevent.Modifiers |= (uint) UnityKeyModifiers.CommandWin; if (keyEvent.keyCode == KeyCode.V) uevent.Character = (uint) 'v'; if (keyEvent.keyCode == KeyCode.A) uevent.Character = (uint) 'a'; if (keyEvent.keyCode == KeyCode.C) uevent.Character = (uint) 'c'; UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent); uevent.Type = 0u; UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent); return; } #endif #endif // encode modifiers uevent.Modifiers = 0; if (keyEvent.command) uevent.Modifiers |= (uint) UnityKeyModifiers.CommandWin; if (keyEvent.alt) uevent.Modifiers |= (uint) UnityKeyModifiers.Alt; if (keyEvent.control) uevent.Modifiers |= (uint) UnityKeyModifiers.Control; if (keyEvent.shift) uevent.Modifiers |= (uint) UnityKeyModifiers.Shift; if (keyEvent.numeric) uevent.Modifiers |= (uint) UnityKeyModifiers.Numeric; if (keyEvent.functionKey) uevent.Modifiers |= (uint) UnityKeyModifiers.FunctionKey; if (keyEvent.capsLock) uevent.Modifiers |= (uint) UnityKeyModifiers.CapsLock; UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent); }
/// <summary> /// Process a Unity keyboard event /// </summary> public void ProcessKeyboard(Event keyEvent) { if (inputDisabled) { return; } UnityKeyEvent uevent = new UnityKeyEvent(); uevent.Type = keyEvent.type == EventType.KeyDown ? 1u : 0u; uevent.KeyCode = (uint)keyEvent.keyCode; uevent.Character = (uint)keyEvent.character; // Fix mac deployment Unity key handling bug #if !UNITY_EDITOR #if UNITY_STANDALONE_OSX if (keyEvent.command && (keyEvent.keyCode == KeyCode.V || keyEvent.keyCode == KeyCode.A || keyEvent.keyCode == KeyCode.C)) { if (keyEvent.type != EventType.KeyDown) { return; } uevent.Type = 1u; uevent.KeyCode = (uint)keyEvent.keyCode; uevent.Modifiers |= (uint)UnityKeyModifiers.CommandWin; if (keyEvent.keyCode == KeyCode.V) { uevent.Character = (uint)'v'; } if (keyEvent.keyCode == KeyCode.A) { uevent.Character = (uint)'a'; } if (keyEvent.keyCode == KeyCode.C) { uevent.Character = (uint)'c'; } UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent); uevent.Type = 0u; UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent); return; } #endif #endif // encode modifiers uevent.Modifiers = 0; if (keyEvent.command) { uevent.Modifiers |= (uint)UnityKeyModifiers.CommandWin; } if (keyEvent.alt) { uevent.Modifiers |= (uint)UnityKeyModifiers.Alt; } if (keyEvent.control) { uevent.Modifiers |= (uint)UnityKeyModifiers.Control; } if (keyEvent.shift) { uevent.Modifiers |= (uint)UnityKeyModifiers.Shift; } if (keyEvent.numeric) { uevent.Modifiers |= (uint)UnityKeyModifiers.Numeric; } if (keyEvent.functionKey) { uevent.Modifiers |= (uint)UnityKeyModifiers.FunctionKey; } if (keyEvent.capsLock) { uevent.Modifiers |= (uint)UnityKeyModifiers.CapsLock; } UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent); }
/// <summary> /// Process a Unity keyboard event /// </summary> public void ProcessKeyboard(Event keyEvent) { if (inputDisabled) return; UnityKeyEvent uevent = new UnityKeyEvent(); uevent.Type = keyEvent.type == EventType.KeyDown ? 1u : 0u; uevent.KeyCode = (uint) keyEvent.keyCode; uevent.Character = (uint) keyEvent.character; // encode modifiers uevent.Modifiers = 0; if (keyEvent.command) uevent.Modifiers |= (uint) UnityKeyModifiers.CommandWin; if (keyEvent.alt) uevent.Modifiers |= (uint) UnityKeyModifiers.Alt; if (keyEvent.control) uevent.Modifiers |= (uint) UnityKeyModifiers.Control; if (keyEvent.shift) uevent.Modifiers |= (uint) UnityKeyModifiers.Shift; if (keyEvent.numeric) uevent.Modifiers |= (uint) UnityKeyModifiers.Numeric; if (keyEvent.functionKey) uevent.Modifiers |= (uint) UnityKeyModifiers.FunctionKey; if (keyEvent.capsLock) uevent.Modifiers |= (uint) UnityKeyModifiers.CapsLock; UWKPlugin.UWK_PostUnityKeyEvent(ID, ref uevent); }
public static extern uint UWK_PostUnityKeyEvent(uint browserID, ref UnityKeyEvent keyEvent);