Unity Odin (实现如图所示效果)(六)

Unity Odin (实现如图所示效果)(六)

在这里插入图片描述

代码

using UnityEngine;

public class Test6 : MonoBehaviour
{
    public MySubClass mySubClass;
}

[System.Serializable]
public class MySubClass
{
    public string text;
    public int num;
    public Vector3 location;
}
using Sirenix.OdinInspector.Editor;
using Sirenix.Utilities;
using Sirenix.Utilities.Editor;
using UnityEditor;
using UnityEngine;

public class MySubClassDraw : OdinValueDrawer<MySubClass>
{
    private InspectorProperty text;
    private InspectorProperty number;
    private InspectorProperty location;

    protected override void Initialize()
    {
        text = this.Property.Children["text"];
        number = this.Property.Children["num"];
        location = this.Property.Children["location"];
    }

    protected override void DrawPropertyLayout(GUIContent label)
    {
        var rect = EditorGUILayout.GetControlRect();
        EditorGUI.PrefixLabel(rect, label);
        rect = EditorGUILayout.GetControlRect();
        
        GUIHelper.PushLabelWidth(75);
        text.ValueEntry.WeakSmartValue = SirenixEditorFields.TextField(rect.Split(1, 2), "Text", (string)text.ValueEntry.WeakSmartValue);
        number.ValueEntry.WeakSmartValue = SirenixEditorFields.IntField(rect.Split(0, 2), "Number", (int)number.ValueEntry.WeakSmartValue);
        location.ValueEntry.WeakSmartValue = SirenixEditorFields.Vector3Field("Location", (Vector3)location.ValueEntry.WeakSmartValue);
        GUIHelper.PopLabelWidth();
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值