Version: 2021.2
言語: 日本語
public static float FloatField (Rect position, float value, GUIStyle style= EditorStyles.numberField);
public static float FloatField (Rect position, string label, float value, GUIStyle style= EditorStyles.numberField);
public static float FloatField (Rect position, GUIContent label, float value, GUIStyle style= EditorStyles.numberField);

パラメーター

position 表示位置
label Float Field の前に表示するオプションのラベル
value 編集する値
style オプションの GUIStyle

戻り値

float ユーザーによって設定された値

説明

Makes a text field for entering floats.


Float Field in an Editor Window.

using UnityEngine;
using UnityEditor;

public class EditorGUIFloatField : EditorWindow { float sizeMultiplier = 1;

[MenuItem("Examples/Scale selected Object")] static void Init() { var window = GetWindow<EditorGUIFloatField>(); window.position = new Rect(0, 0, 210, 30); window.Show(); }

void OnGUI() { sizeMultiplier = EditorGUI.FloatField(new Rect(3, 3, 150, 20), "Increase scale by:", sizeMultiplier);

if (GUI.Button(new Rect(160, 3, 45, 20), "Scale!")) { Selection.activeTransform.localScale = Selection.activeTransform.localScale * sizeMultiplier; } } }