Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

GUI.TextField

マニュアルに切り替える
public static string TextField(Rect position, string text);
public static string TextField(Rect position, string text, int maxLength);
public static string TextField(Rect position, string text, GUIStyle style);
public static string TextField(Rect position, string text, int maxLength, GUIStyle style);

パラメーター

position テキストフィールドを描画するスクリーン上の Rect
text 編集するテキスト。この関数が返す値は以下の例のように同じ変数に格納しなおすべきです
maxLength 文字列の最大の長さ。省略した場合は無制限に入力することができます
style 使用するスタイル。省略された場合は、現在の GUISkin にある textField スタイルを使用します

戻り値

string 編集された文字列

説明

ユーザーが文字列を編集することができるテキストエリア

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public string stringToEdit = "Hello World"; void OnGUI() { stringToEdit = GUI.TextField(new Rect(10, 10, 200, 20), stringToEdit, 25); } }