Boat Attack使用了Universal RP的许多新图形功能,可以用于探索 Universal RP 的使用方式和技巧。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

43 行
1.1 KiB

using System;
using System.Collections.Generic;
namespace UnityEngine.Rendering
{
//
// Unity can't serialize Dictionary so here's a custom wrapper that does. Note that you have to
// extend it before it can be serialized as Unity won't serialized generic-based types either.
//
// Example:
// public sealed class MyDictionary : SerializedDictionary<KeyType, ValueType> {}
//
[Serializable]
public class SerializedDictionary<K, V> : Dictionary<K, V>, ISerializationCallbackReceiver
{
[SerializeField]
List<K> m_Keys = new List<K>();
[SerializeField]
List<V> m_Values = new List<V>();
public void OnBeforeSerialize()
{
m_Keys.Clear();
m_Values.Clear();
foreach (var kvp in this)
{
m_Keys.Add(kvp.Key);
m_Values.Add(kvp.Value);
}
}
public void OnAfterDeserialize()
{
for (int i = 0; i < m_Keys.Count; i++)
Add(m_Keys[i], m_Values[i]);
m_Keys.Clear();
m_Values.Clear();
}
}
}