【Unity编辑器扩展基础】、EditorGUILayout (一)

本文详细介绍了Unity编辑器中GUILayoutField的使用方法,包括各种输入框如ColorField、CurveField、DelayedField等的特性及实例代码。通过具体示例展示了如何在EditorGUILayout中创建不同类型的Field。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

小结:

1、EditorGUILayout的各种Field和GUILayout的类似,但是EditorGUILayout可以复制粘贴;

2、因为OnGUI是每帧执行的,EditorGUILayout中类似TextField、IntSlider、ColorField需要传一个值,返回修改值的,需要将返回值赋值给临时变量;

3、params GUILayoutOption[] options可以传的参数在GUILayout类中可以找到: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight

4、DelayedField延迟的输入框  在按下回车键或将焦点从文本字段移开之前,不会返回新值。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;

public class EditorGUILayoutFieldExample : EditorWindow
{
    #region Field
    //BoundsField
    static Vector3 center = new Vector3(1, 2, 3);
    static Vector3 size = new Vector3(1, 2, 3);
    Bounds _bounds = new Bounds(center, size);

    //ColorField
    Color m_color = Color.white;

    //CurveField
    An
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值