private void OnGUI() { if (Application.platform == RuntimePlatform.OSXEditor) { if (_webViewIntPtr != IntPtr.Zero && !_hidden) { Vector3 pos = Input.mousePosition; bool down = Input.GetMouseButton(0); bool press = Input.GetMouseButtonDown(0); bool release = Input.GetMouseButtonUp(0); float deltaY = Input.GetAxis("Mouse ScrollWheel"); bool keyPress = false; string keyChars = ""; short keyCode = 0; if (_inputString.Length > 0) { keyPress = true; keyChars = _inputString.Substring(0, 1); keyCode = (short)_inputString[0]; _inputString = _inputString.Substring(1); } UniWebViewPlugin.InputEvent(gameObject.name, (int)(pos.x - _webViewRect.x), (int)(pos.y - _webViewRect.y), deltaY, down, press, release, keyPress, keyCode, keyChars, _texture.GetNativeTextureID()); GL.IssuePluginEvent((int)_webViewIntPtr); Matrix4x4 m = GUI.matrix; GUI.matrix = Matrix4x4.TRS(new Vector3(0, Screen.height, 0), Quaternion.identity, new Vector3(1, -1, 1)); GUI.DrawTexture(_webViewRect, _texture); GUI.matrix = m; } } }
/// <summary> /// Process the input event. /// </summary> /// <param name="state"> /// Specifies the input status value. /// 0: mouse moving. /// 1: mouse button down. /// 2: mouse button up. /// 3: mouse wheel /// </param> /// <param name="key"> /// Specifies which key handles the input. /// 0: left mouse button (in case of state 1 and 2) /// 1: right mouse button (in case of state 1 and 2) /// 2: middle mouse button (in case of state 1 and 2) /// delta value: in case of state 3 /// </param> /// <param name="x">The current x coordinate value of the mouse pointer.</param> /// <param name="y">The current x coordinate value of the mouse pointer.</param> public void InputEvent(int state, int key, int x, int y) { Setup(); #if UNIWEBVIEW3_SUPPORTED UniWebViewInterface.InputEvent(listener.Name, state, key, x, y); #elif UNIWEBVIEW2_SUPPORTED UniWebViewPlugin.InputEvent(listener.Name, state, key, x, y); #else WWebViewPlugin.InputEvent(listener.Name, state, key, x, y); #endif }
private void OnGUI() { if (Application.platform == RuntimePlatform.OSXEditor) { if (_webViewId != 0 && !_hidden) { Vector3 pos = Input.mousePosition; bool down = Input.GetMouseButton(0); bool press = Input.GetMouseButtonDown(0); bool release = Input.GetMouseButtonUp(0); float deltaY = Input.GetAxis("Mouse ScrollWheel"); bool keyPress = false; string keyChars = ""; short keyCode = 0; if (!string.IsNullOrEmpty(_inputString)) { keyPress = true; keyChars = _inputString.Substring(0, 1); keyCode = (short)_inputString[0]; _inputString = _inputString.Substring(1); } var id = _texture.GetNativeTexturePtr().ToInt32(); #if !UNITY_ANDROID UniWebViewPlugin.InputEvent(gameObject.name, (int)(pos.x - _webViewRect.x), (int)(pos.y - _webViewRect.y), deltaY, down, press, release, keyPress, keyCode, keyChars, id); #endif #if UNITY_5_0 || UNITY_5_1 || UNITY_5_2_0 || UNITY_EDITOR GL.IssuePluginEvent(_webViewId); #else GL.IssuePluginEvent(UniWebViewPlugin.GetRenderEventFunc(), _webViewId); #endif Matrix4x4 m = GUI.matrix; GUI.matrix = Matrix4x4.TRS(new Vector3(0, Screen.height, 0), Quaternion.identity, new Vector3(1, -1, 1)); GUI.DrawTexture(_webViewRect, _texture); GUI.matrix = m; } } }