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);