상세 컨텐츠

본문 제목

[Unity] 유니티 모바일 디바이스 소프트키보드 관련

게임엔진관련/유니티 엔진

by AlrepondTech 2019. 4. 7. 02:32

본문

반응형

 

 

 

=================================

=================================

=================================

 

 

 

 

 

 

 

출처: https://docs.unity3d.com/kr/530/ScriptReference/TouchScreenKeyboard-text.html

TouchScreenKeyboard.text
public string text;
Description
키보드에 입력 필드에 의해 보이는 텍스트를 반환합니다.

이 값은 사용자가 입력을 마치지 않은 상황에서도, 언제든지 접근이 가능합니다.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
public string inputText = "text";
private TouchScreenKeyboard keyboard;
// Updates button's text while user is typing
void OnGUI() {
if (GUI.Button(new Rect(0, 10, 200, 32), inputText))
keyboard = TouchScreenKeyboard.Open(inputText);

if (keyboard != null)
inputText = keyboard.text;

}  

}

 

 

=================================

=================================

=================================

 

 

출처: https://answers.unity.com/questions/405820/how-to-save-text-and-display-using-touch-screen-ke.html

#pragma strict

public var kBoardString : String = "";

private var tempString : String = "";
private var keyboard : iPhoneKeyboard;
private var iskBoardOpen : boolean = false;

function Update()
{
kBoard0();
}

function kBoard0()
{
// keyboard = iPhoneKeyboard.Open( tempName : String, iPhoneKeyboardType.Default, Auto-Correct, Multi-Line, Secure, Alert, "Text Placeholder" );

 if ( !iskBoardOpen )   
 {  
     keyboard = [iPhoneKeyboard.Open(](iPhoneKeyboard.Open() tempString, iPhoneKeyboardType.Default, false, false, false, false, "Default Keyboard" );  
     iskBoardOpen = true;  
 }  

 if ( [keyboard.done](keyboard.done) )   
 {  
     kBoardString = [keyboard.text;](keyboard.text;)  
     tempString = "";  
     iskBoardOpen = false;  
 }  
 else  
 {  
     kBoardString = [keyboard.text;](keyboard.text;)  
 }  

}

 

 

 

 

 

반응형

 

 

728x90

 

 

=================================

=================================

=================================

 

 

TouchScreenKeyboard.active

public boolactive;

Description

키보드를 화면에 보여줄지 지정합니다.

화면에서 가려져있던 키보드를 다시 화면에 보여줄 때 사용합니다.

// Hides the keyboard if the device is facing down
// and resumes input if the device is facing up.

private var keyboard : TouchScreenKeyboard;

function Update() {
    if (keyboard != null)
    {
        if (Input.deviceOrientation == DeviceOrientation.FaceDown)
            keyboard.active = false;
        if (Input.deviceOrientation == DeviceOrientation.FaceUp)
            keyboard.active = true;
    }
}
function OnGUI() {
    if (GUI.Button(Rect(0, 10, 200, 32), "Open keyboard"))
        keyboard = TouchScreenKeyboard.Open("text");
}

 

=================================

=================================

=================================

 

 

 

반응형


관련글 더보기

댓글 영역