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

对应展示

相关推荐
The Future is mine1 小时前
C# new Bitmap(32043, 32043, PixelFormat.Format32bppArgb)报错:参数无效,如何将图像分块化处理?
开发语言·c#
星火撩猿5 小时前
常见游戏引擎介绍与对比
unity·ue5·游戏引擎·godot
sky_smile_Allen6 小时前
[Unity]-[UI]-[Prefab] 关于Unity UGUI 的布局及组件讲解
ui·unity·游戏引擎
Iotfsd8 小时前
.NET写的开源工业物联网网关(IoTGateway)
物联网·c#·.net·dotnet·边缘网关·雾计算·工业物联网智能网关
先生沉默先9 小时前
c#接口_抽象类_多态学习
开发语言·学习·c#
江沉晚呤时9 小时前
深入了解C# List集合及两种常见排序算法:插入排序与堆排序
windows·sql·算法·oracle·c#·排序算法·mybatis
iReachers9 小时前
使用命令行加密混淆C#程序
开发语言·c#
[太阳]8810 小时前
Kafka命令行的使用/Spark-Streaming核心编程(二)
c#·linq
太妃糖耶12 小时前
URP-利用矩阵在Shader中实现物体的平移和缩放
unity·矩阵
电商api接口开发1 天前
ASP.NET MVC 入门指南
c#·asp.net·mvc