From bef9962a23ff5fdcaa8d92f3b1419596df80dc97 Mon Sep 17 00:00:00 2001 From: kou_yeung Date: Wed, 26 Jul 2023 11:40:48 +0900 Subject: [PATCH] =?UTF-8?q?#116=20=E3=81=AB=E3=81=A6=E3=80=81=E3=83=A2?= =?UTF-8?q?=E3=83=90=E3=82=A4=E3=83=AB=E3=83=87=E3=83=90=E3=82=A4=E3=82=B9?= =?UTF-8?q?=E3=81=A7=E3=82=B2=E3=83=BC=E3=83=A0=E3=83=A9=E3=82=A4=E3=82=AF?= =?UTF-8?q?=E3=81=AE=E5=85=A5=E5=8A=9B=E3=82=92=E5=88=87=E3=82=8A=E6=9B=BF?= =?UTF-8?q?=E3=81=88=E3=82=89=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=B9=E3=83=9A=E3=82=AF=E3=82=BF=E3=83=BC?= =?UTF-8?q?=E3=81=8B=E3=82=89=E6=8C=87=E5=AE=9A=E5=8F=AF=E8=83=BD=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/WebGLSupport/WebGLInput/WebGLInput.cs | 4 +- .../WebGLSupport/WebGLInput/WebGLInput.jslib | 37 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Assets/WebGLSupport/WebGLInput/WebGLInput.cs b/Assets/WebGLSupport/WebGLInput/WebGLInput.cs index b098aac..2060f11 100644 --- a/Assets/WebGLSupport/WebGLInput/WebGLInput.cs +++ b/Assets/WebGLSupport/WebGLInput/WebGLInput.cs @@ -121,6 +121,8 @@ static WebGLInput() [TooltipAttribute("show input element on canvas. this will make you select text by drag.")] public bool showHtmlElement = false; + [TooltipAttribute("show input element above keyboard (mobile only)")] + public bool useGameLikeInput = true; private IInputField Setup() { @@ -181,7 +183,7 @@ public void OnSelect() // モバイルの場合、強制表示する var isHidden = !(showHtmlElement || Application.isMobilePlatform); - id = WebGLInputPlugin.WebGLInputCreate(WebGLInput.CanvasId, rect.x, rect.y, rect.width, rect.height, fontSize, input.text, input.placeholder, input.lineType != LineType.SingleLine, isPassword, isHidden, Application.isMobilePlatform); + id = WebGLInputPlugin.WebGLInputCreate(WebGLInput.CanvasId, rect.x, rect.y, rect.width, rect.height, fontSize, input.text, input.placeholder, input.lineType != LineType.SingleLine, isPassword, isHidden, Application.isMobilePlatform && useGameLikeInput); instances[id] = this; WebGLInputPlugin.WebGLInputEnterSubmit(id, input.lineType != LineType.MultiLineNewline); diff --git a/Assets/WebGLSupport/WebGLInput/WebGLInput.jslib b/Assets/WebGLSupport/WebGLInput/WebGLInput.jslib index a5fd7d9..421ec38 100644 --- a/Assets/WebGLSupport/WebGLInput/WebGLInput.jslib +++ b/Assets/WebGLSupport/WebGLInput/WebGLInput.jslib @@ -5,7 +5,7 @@ var WebGLInput = { // if Runtime not defined. create and add functon!! if(typeof Runtime === "undefined") Runtime = { dynCall : dynCall } }, - WebGLInputCreate: function (canvasId, x, y, width, height, fontsize, text, placeholder, isMultiLine, isPassword, isHidden, isMobile) { + WebGLInputCreate: function (canvasId, x, y, width, height, fontsize, text, placeholder, isMultiLine, isPassword, isHidden, useGameLikeInput) { var container = document.getElementById(UTF8ToString(canvasId)); var canvas = container.getElementsByTagName('canvas')[0]; @@ -30,26 +30,23 @@ var WebGLInput = { height *= scaleY; } } - var input = document.createElement(isMultiLine?"textarea":"input"); input.style.position = "absolute"; - - if(isMobile) { - input.style.bottom = 1 + "vh"; - input.style.left = 5 + "vw"; - input.style.width = 90 + "vw"; - input.style.height = (isMultiLine? 18 : 10) + "vh"; - input.style.fontSize = 5 + "vh"; - input.style.borderWidth = 5 + "px"; - input.style.borderColor = "#000000"; - } else { - input.style.top = y + "px"; - input.style.left = x + "px"; - input.style.width = width + "px"; - input.style.height = height + "px"; - input.style.fontSize = fontsize + "px"; - } - + if(useGameLikeInput) { + input.style.bottom = 1 + "vh"; + input.style.left = 5 + "vw"; + input.style.width = 90 + "vw"; + input.style.height = (isMultiLine? 18 : 10) + "vh"; + input.style.fontSize = 5 + "vh"; + input.style.borderWidth = 5 + "px"; + input.style.borderColor = "#000000"; + } else { + input.style.top = y + "px"; + input.style.left = x + "px"; + input.style.width = width + "px"; + input.style.height = height + "px"; + input.style.fontSize = fontsize + "px"; + } input.style.outlineWidth = 1 + 'px'; input.style.opacity = isHidden?0:1; input.style.resize = 'none'; // for textarea @@ -66,7 +63,7 @@ var WebGLInput = { input.type = 'password'; } - if(isMobile) { + if(useGameLikeInput) { document.body.appendChild(input); } else { container.appendChild(input);