Odin包含一個Serialization Debugger工具,用于調(diào)試查看對應(yīng)的序列化信息.
如果在Inspector中的字段等序列化信息出現(xiàn)丟失或者不可見等問題灼芭,可以使用Serialization Debugger進行快速查看并定位問題证薇。
調(diào)試器將顯示正在序列化任何給定類型的成員忧便,以及它們是否被Unity佳恬,Odin或兩者序列化卷仑。它還提供成員序列化方式的介紹信息寞蚌。
打開Serialization Debugger工具有兩種方式
- Tools/Odin Inspector/Serialization Debugger
- 右鍵點擊已經(jīng)成為組件的腳本田巴,選擇Debug Serialization
在Serialization Debugger面板中會查看對應(yīng)的字段的序列化形式,是以O(shè)din序列化還是Unity自帶的序列化挟秤,點擊對應(yīng)的字段在下方也會也有相對應(yīng)的提示壹哺。
而且腳本列表和搜索框,可以快速定位需要查看的腳本序列化
對應(yīng)示例腳本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
using Sirenix.Serialization;
using System;
public class SerializationDebugger_ExampleOne : MonoBehaviour
{
public string UnityString = "Unity_菜鳥海瀾";
public List<string> UnityStringList = new List<string>();
[NonSerialized][OdinSerialize]
public string OdinStringInvalid= "錯誤序列化";
public TempUnitySerializationData tempUnitySerializationData = new TempUnitySerializationData();
public TempOdinSerializationData tempOdinSerializationData = new TempOdinSerializationData();
public List<TempUnitySerializationData> UnityList = new List<TempUnitySerializationData>();
public Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
void Start()
{
}
}
[Serializable]
public class TempUnitySerializationData
{
public string UnityString = "菜鳥海瀾";
}
public class TempOdinSerializationData
{
public string UnityString = "菜鳥海瀾";
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
using Sirenix.Serialization;
using System;
public class SerializationDebugger_ExampleTwo : SerializedMonoBehaviour
{
public string UnityString = "Unity_菜鳥海瀾";
[OdinSerialize]
public string OdinAndUnityString = "OdinAndUnity_菜鳥海瀾";
[OdinSerialize][NonSerialized]
public string OdinString = "Odin_菜鳥海瀾";
public List<TempOdinSerializationData> OdinList = new List<TempOdinSerializationData>();
[SerializeField]
public TempUnitySerializationData tempUnitySerializationData = new TempUnitySerializationData();
public TempOdinSerializationData tempOdinSerializationData = new TempOdinSerializationData();
public Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
void Start()
{
}
}