Last active
October 4, 2019 17:47
-
-
Save kazumalab/704949bacc477a126381d3915625a329 to your computer and use it in GitHub Desktop.
sample class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class TestInput : MonoBehaviour | |
{ | |
private Image image; | |
private Vector2 initPosition; | |
private InputField inputField; | |
private bool isActive = false; | |
private void Start() | |
{ | |
image = GetComponent<Image>(); | |
inputField = GetComponentInChildren<InputField>(); | |
initPosition = image.rectTransform.anchoredPosition; | |
} | |
private void Update() | |
{ | |
if(!isActive && this.inputField.isFocused) | |
{ | |
isActive = true; | |
InputStart(); | |
} | |
if(isActive && !this.inputField.isFocused) | |
{ | |
isActive = false; | |
InputEnd(); | |
} | |
} | |
public void InputStart() | |
{ | |
TouchScreenKeyboard.hideInput = false; | |
float height = TouchScreenKeyboard.area.height; | |
Debug.Log("height >> " + height); | |
image.rectTransform.anchoredPosition = Vector2.up * height; | |
} | |
public void InputEnd() | |
{ | |
image.rectTransform.anchoredPosition = initPosition; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment