using System.Collections.Generic;using UnityEngine;using Sirenix.OdinInspector;publicclassDicTest:SerializedMonoBehaviour{publicDictionary<int,string>prefabDataDic=newDictionary<int,string>();} 实现效果如下: Odin插件时Unity中比较常用的编辑器扩展插件,可以帮助我们在监视器面板中自定义多种显示效果,后面会专门出...
一个最简单的window: Attribute在EditorWindow同样,重写OdinEditorWindow的GetTarget的方法可以显示任何信息 带菜单的OdinMenuEditorWindow 3.序列化 直接继承以下的类就可以在Inspector显示Dictionary,但是Odin官方建议,由于Odin的序列化实现是将Unity不序列化的所有数据转换为Unity可以理解的数据存储格式以及Object List,然后Un...
在Inspector上显示字典,这个比较特殊,需要用到Odin的序列化功能才行,而且字典所在的脚本必须继承Odin序列化后的SerializedMonoBehaviour publicclassOdinTest:SerializedMonoBehaviour{[DictionaryDrawerSettings]publicDictionary<string,float>StudentDict=newDictionary<string,float>();} 然后Unity编译后会出现如下提示信息,点击隐...
原文链接:Odin Serializer Quick Start | Odin Inspector for Unity 缺点:需要继承SerializedMonoBehaviour代替MonoBehaviour,侵入性的接口。 4. 使用List模拟字典的键值对,内部使用一个字典存储键的索引,在运行时更改字典可将修改反映到List(Inspector)上,并使用ReorderableList和PropertyDrawer自定义绘制方法。 原文链接:Serial...
myDictionary字段是一个字典,键为字符串,值为整数,我们通过[ShowInInspector]特性确保它可以在Inspector面板中显示和编辑。 5. 可能遇到的问题及解决方案 在使用Odin进行字典序列化时,可能会遇到一些问题,例如字典中的数据在Inspector面板中显示不正确或无法编辑。这通常是由于数据类型不兼容或Odin的特性使用不当造成的...
1)下载OdinSerializer 序列化插件 2)定义序列化类 unity中的inspector面板支持list,但是有时候我们需要Dictionary,尤其是我们需要通过asset资源与ScriptableObject脚本一起实现序列化时更是需要如此。如:技能需要通过id来确定访问单个技能数据,那必须满足key和Value的数据结构。
ResponsiveButtonGroup根据界面自适应,但使用频率不高。DictionaryDrawerSettings用于在Inspector中展示字典,需要Odin序列化功能,且脚本需继承特定类,添加时的键重复检查颇具人性化。接着是ListDrawerSettings,支持List的渲染,可调整元素顺序,且支持关闭拖拽功能。TableList将List以表格形式呈现,具备自定义列宽...
在Unity中,字典无法在Inspector中进行序列化显示。通过深入探索,发现了几种方法。然而,每种方法都有其局限性。使用foreach遍历字典的每一步都需要手动编写,且在运行过程中无法与字典动态绑定。另一种方法涉及使用两个List来保存键和值,这需要为每种类型的字典创建一个类,不够灵活。接着,使用Odin ...
Odin Inspector is a plugin for Unity that lets you enjoy all the workflow benefits of having a powerful, customized and user-friendly editor, without ever having to write a single line of custom editor code. Instead of writing and maintaining thousands of lines of custom editor code, developers...
Of course, these UnitySerializedDictionaries can be like any normal Dictionary, and even show up in Odin Inspector as ordinary Dictionaries. Do note that there may be some strange interactions with Unity's prefab modification system, and prefab-modified values may not properly show up as such in...