Odin插件基本使用

介绍

Odin Inspector是Unity的一个插件,让您可以享受拥有强大,自定义和用户友好编辑器的所有工作流程优势,而无需编写任何自定义编辑器代码。

安装

需要有对应的unity包或者去官网或者资源商店下载

官方网址

Odin Inspector and Serializer | Improve your workflow in Unity

用处

有着许多能力强大的特性

案例与基本使用方法

cs 复制代码
using Sirenix.OdinInspector;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(fileName ="GameConfig",menuName ="Config")]
public class Config : SerializedScriptableObject
{
    [LabelText("姓名")]
    public string name;
    [LabelText("路径")]
    public string path;

    [LabelText("坐标")]
    [MinMaxSlider(0, 2)]
    public Vector2 vector2;

    [LabelText("数字")]
    [Range(1,3)]
    public int num;

    [SerializeField]
    [DictionaryDrawerSettings(KeyLabel ="ID",ValueLabel ="值")]
    private Dictionary<int, Data> dic;

    [Button("初始化",ButtonHeight =40)]
    [GUIColor(0,1,0)]
    void Init()
    {
        Debug.Log("Init");
        dic[1].dataID = "3";
    }
}

[Serializable]
public class Data
{
    [LabelText("数据ID")]
    public string dataID;
    [LabelText("数据Key")]
    [Range(1,300)]
    public int dataKey;
}

解释与注意事项

需要继承SerializedScriptableObject才能在面板上显示字典容器

对应展示

相关推荐
太阳的后裔24 分钟前
随笔一些用C#封装的控件
开发语言·c#
lrh30256 小时前
Custom SRP - Complex Maps
unity·srp·render pipeline
m0_4972141510 小时前
unity中通过拖拽,自定义scroll view中子物体顺序
unity·游戏引擎
地狱为王13 小时前
在Unity中实现DTLN-AEC处理音频文件的功能
unity·aec·降噪
ISDF-工软未来14 小时前
C# 泛型简单案例
c#
疯狂的维修17 小时前
C#中一段程序类比博图
c#
时光追逐者18 小时前
C#/.NET/.NET Core技术前沿周刊 | 第 53 期(2025年9.1-9.7)
c#·.net·.netcore
冷冷的菜哥18 小时前
ASP.NET Core使用MailKit发送邮件
后端·c#·asp.net·发送邮件·mailkit
weixin_4471035819 小时前
C#之LINQ
c#·linq
ysn1111119 小时前
反编译分析C#闭包
c#