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才能在面板上显示字典容器

对应展示

相关推荐
从孑开始4 小时前
ManySpeech.MoonshineAsr 使用指南
人工智能·ai·c#·.net·私有化部署·语音识别·onnx·asr·moonshine
YuanlongWang4 小时前
C# 中,依赖注入(DI)的实现方式
c#
SmartSoftHelp开发辅助优化6 小时前
C# WinForm 编程高手:程序,进程,线程。程序,窗体,UI,后台。是如何协调工作的?深度解析>SmartSoftHelp魔法精灵工作室
microsoft·ui·c#
future_studio8 小时前
聊聊 Unity(小白专享、C# 小程序 之 加密存储)
开发语言·小程序·c#
c#上位机8 小时前
MefBootstrapper在Prism引导程序中的使用
c#·wpf·prism
玩泥巴的11 小时前
.NET驾驭Word之力:基于规则自动生成及排版Word文档
c#·word·.net·com互操作
SunnyDays101112 小时前
C# 实现高保真 Excel 转 PDF(无需 Office 环境)
经验分享·c#·excel转pdf
攻城狮CSU12 小时前
C# 数据加载专题 之泛型序列化
java·servlet·c#
爱编程的鱼12 小时前
C# 参数详解:从基础传参到高级应用
开发语言·microsoft·c#
流水线上的指令侠14 小时前
使用C#写微信小程序后端——电商微信小程序
微信小程序·小程序·c#·visual studio