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(可选)显示在浮点字段前的标签。
value要编辑的值。
style可选 GUIStyle

返回

float 用户输入的值。

描述

创建一个用于输入浮点数的文本字段。


Float Field in an Editor Window.

// Editor Script that multiplies the scale of the current selected GameObject

class EditorGUIFloatField extends EditorWindow {

var sizeMultiplier : float = 1;

@MenuItem("Examples/Scale selected Object") static function Init() { var window = GetWindow(EditorGUIFloatField); window.position = Rect(0, 0, 210, 30); window.Show(); }

function OnGUI() { sizeMultiplier = EditorGUI.FloatField(Rect(3,3,150, 20), "Increase scale by:", sizeMultiplier); if(GUI.Button(Rect(160,3,45,20), "Scale!")) Selection.activeTransform.localScale = Selection.activeTransform.localScale * sizeMultiplier; } }