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

对应展示

相关推荐
@蓝莓果粒茶2 小时前
LeetCode第350题_两个数组的交集II
c++·python·学习·算法·leetcode·职场和发展·c#
3 小时前
3D碰撞检测系统 基于SAT算法+Burst优化(Unity)
算法·3d·unity·c#·游戏引擎·sat
「QT(C++)开发工程师」6 小时前
Qt C++动态库SDK在Visual Studio 2022使用(C++/C#版本)
c++·qt·c#·visual studio
dzj20218 小时前
Unity是如何把3D场景显示到屏幕上的——Unity的渲染过程
3d·unity·游戏引擎·渲染·图形学
中游鱼14 小时前
如何序列化和反序列化动态 XmlElement ?
windows·microsoft·c#
唐青枫21 小时前
C#.NET dapper 详解
c#·.net
死也不注释1 天前
【鸡零狗碎记录】
unity·c#
Maybe_ch1 天前
.NET-键控服务依赖注入
开发语言·c#·.net
★YUI★1 天前
学习游戏制作记录(剑投掷技能)7.26
学习·游戏·unity·c#
小乖兽技术1 天前
C#与C++交互开发系列(二十四):WinForms 应用中嵌入C++ 原生窗体
c++·c#·交互