Serialized Dictionary Pro is an easy to use system that allows to make serializable dictionaries on Unity. There are no limitations on key or value types other than Unitys own serialization limitations.
Main Pro Features
Now with 6 different data types, not just Dictionaries
System has been completely modified to use way less memory
Can now be converted to Json without including any extra data or any extra step
No reflection and required references field used for keys
Editor callbacks for ItemRemoved, ItemAdded, ElementDrawn, ItemsReordered, and EntryEdited
New constructor values to block adding items, removing items, items reorder, and make it read only
Faster deserialization logic thanks to not using reflection
Features
Reordering of items (Drag & Drop)
Pages System
Custom key or value drawer
Data structures are separated into their own class:
[System.Serializable]
public class MyDictionary : SerializableDictionary<Key, Value> { }
[System.Serializable]
public class MyDictionary : SerializableOrderedDictionary<Key, Value> { }
[System.Serializable]
public class MyDictionary : SerializableSortedDictionary<Key, Value> { }
[System.Serializable]
public class MyDictionary : SerializableHashSet<Key> { }
[System.Serializable]
public class MyDictionary : SerializableBiDictionary<Key, Value> { }
[System.Serializable]
public class MyDictionary : SerializableLinkedList<Key> { }
I find Lite ver and Pro ver operation is not the same
The Lite ver when add new Data will auto gray used item, and select not used item,
but Pro ver when add new Data not auto gray item, and seems select first itme , may only except null.
Could you take a look?
Lite ver
Pro ver
public enum Side
{
Null = -1,
Right = 0,
TopRight = 1,
Top = 2,
TopLeft = 3,
Left = 4,
BottomLeft = 5,
Bottom = 6,
BottomRight = 7
}
[System.Serializable]
public class DictionarySideHitLimits : SerializableDictionaryBase<Side, int> { }
[SerializeField]
DictionarySideHitLimits _SideHitLimits;
public IDictionary<Side, int> m_SideHitLimits
{
get { return _SideHitLimits; }
set { _SideHitLimits.CopyFrom(value); }
}
Hi:
I recently bought your Pro version and I’m having a strange behavior when I try to remove things from the dictionary by code:
I have: public class myClass: SerializableDictionary<Vector2,int>{}
I now managed to make it work properly. What changed is that I was using 2 inspectors, one locked on the Scriptable object containing the dictionary, and the other (unlocked) inspecting the object that I use in the editor to read the scene events and modify the dictionary accordingly. I unlocked both inspectors, and It worked.
Very strange, but in any case, I know how to make it work now.
I have successfully created and added to a serializedDictionary:
using RotaryHeart.Lib.SerializableDictionary;
using UnityEngine;
namespace Optkl.Data
{
[CreateAssetMenu()]
public class SingleStrike : ScriptableObject
{
[SerializeField]
private MainDict strikeData;
public MainDict StrikeData
{
get
{
return strikeData;
}
set
{
strikeData = value;
}
}
[System.Serializable]
public class StrikeMinMax
{
public float maxStrike;
public float minStrike;
}
[System.Serializable]
public class MainDict : SerializableDictionaryBase<string, StrikeMinMax> { }
public void Add (string expireDate, StrikeMinMax strikeMinMax)
{
strikeData.Add(expireDate, strikeMinMax);
}
}
}
I have also successfully converted this to a nested dictionary:
using RotaryHeart.Lib.SerializableDictionary;
using UnityEngine;
namespace Optkl.Data
{
[CreateAssetMenu()]
public class DataStrike : ScriptableObject
{
[SerializeField]
public MainDict tradeDate;
}
[System.Serializable]
public class StrikeData
{
public NestedDict expireDate;
}
[System.Serializable]
public class StrikeMinMax
{
public float strikeMax;
public float strikeMin;
}
[System.Serializable]
public class MainDict : SerializableDictionaryBase<string, StrikeData> { }
[System.Serializable]
public class NestedDict : SerializableDictionaryBase<string, StrikeMinMax> { }
}
But I can’t figure out the steps to add data to the nested database. It’s quite a bit more complex than I thought it would be. How do I modify my code from the single entry to the nested one?