Skip to content

Instantly share code, notes, and snippets.

@kazumalab kazumalab/hello.rb
Last active Oct 4, 2019

Embed
What would you like to do?
sample class
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
You can’t perform that action at this time.