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

对应展示

相关推荐
benben0441 小时前
Unity3D仿星露谷物语开发44之收集农作物
前端·游戏·unity·游戏引擎
动感光博2 小时前
Unity(URP渲染管线)的后处理、动画制作、虚拟相机(Virtual Camera)
开发语言·人工智能·计算机视觉·unity·c#·游戏引擎
hie988944 小时前
C#与KepOPC通讯
开发语言·c#
hweiyu005 小时前
C#学习教程(附电子书资料)
开发语言·学习·c#
csdn_aspnet7 小时前
C# DataGridView 选中所有复选框
c#·winform·datagridview
MWHLS10 小时前
【以及好久没上号的闲聊】Unity记录8.1-地图-重构与优化
unity·开源
qq_2979080110 小时前
c#车检车构客户管理系统软件车辆年审短信提醒软件
sqlserver·c#·开源软件
酷炫码神11 小时前
C#数组与集合
开发语言·c#
钢铁男儿11 小时前
C# 深入理解类(静态函数成员)
java·开发语言·c#
CoderIsArt20 小时前
参数系统的基类Parameter抽象类
c#