position | 屏幕上用于浮点字段的矩形。 |
label | (可选)显示在浮点字段前的标签。 |
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; } } }