CORE dashboard + a lot of changes
This commit is contained in:
@@ -8,26 +8,29 @@ namespace RPGCoreCommon.Helpers.CustomTypes
|
||||
[Serializable]
|
||||
public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, ISerializationCallbackReceiver
|
||||
{
|
||||
[SerializeField] internal TKey _tempKey;
|
||||
[Serializable]
|
||||
internal class Pair
|
||||
{
|
||||
[SerializeReference] internal TKey _key;
|
||||
[SerializeReference] internal TValue _value;
|
||||
}
|
||||
|
||||
[SerializeReference] internal TKey _tempKey;
|
||||
[SerializeField] internal List<Pair> _pairs;
|
||||
|
||||
[SerializeField] internal List<TKey> _keys = new();
|
||||
[SerializeReference] internal List<TValue> _values = new();
|
||||
|
||||
public void OnBeforeSerialize()
|
||||
{
|
||||
_keys = Keys.ToList();
|
||||
_values = Values.ToList();
|
||||
_pairs = this.Select(p => new Pair { _key = p.Key, _value = p.Value }).ToList();
|
||||
}
|
||||
|
||||
public void OnAfterDeserialize()
|
||||
{
|
||||
Clear();
|
||||
for (var i = 0; i < _keys.Count; i++)
|
||||
{
|
||||
if (_keys[i] != null) Add(_keys[i], _values[i]);
|
||||
}
|
||||
|
||||
_keys.Clear();
|
||||
_values.Clear();
|
||||
_pairs.ForEach(p => TryAdd(p._key, p._value));
|
||||
_pairs.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@ using UnityEngine;
|
||||
namespace RPGCoreCommon.Helpers.CustomTypes
|
||||
{
|
||||
[Serializable]
|
||||
public class SerializableType : ISerializationCallbackReceiver, ICloneable
|
||||
public class SerializableType : ISerializationCallbackReceiver, ICloneable, IEquatable<SerializableType>
|
||||
{
|
||||
public Type type { get; internal set; }
|
||||
[SerializeField] internal string assemblyQualifiedName;
|
||||
public Type type { get; private set; }
|
||||
[SerializeField] private string assemblyQualifiedName;
|
||||
|
||||
public SerializableType(Type type)
|
||||
{
|
||||
@@ -32,5 +32,9 @@ namespace RPGCoreCommon.Helpers.CustomTypes
|
||||
public static implicit operator Type(SerializableType serializableType) => serializableType.type;
|
||||
|
||||
public static implicit operator SerializableType(Type type) => new(type);
|
||||
|
||||
public override int GetHashCode() => type?.GetHashCode() ?? 0;
|
||||
|
||||
public bool Equals(SerializableType other) => type == other?.type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RPGCoreCommon.Helpers.PropertyAttributeDrawers
|
||||
{
|
||||
public class ObjectPickerAttribute : PropertyAttribute
|
||||
{
|
||||
// TODO: zrobić to + drawer ObjectPickerDrawer
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37be47854eb74f7a8558e9ef3de059b3
|
||||
timeCreated: 1781877714
|
||||
+1
-1
@@ -4,6 +4,6 @@ namespace RPGCoreCommon.Helpers.PropertyAttributeDrawers
|
||||
{
|
||||
public class SerializeReferenceHelperAttribute : PropertyAttribute
|
||||
{
|
||||
|
||||
// TODO: zrobić to + drawer SerializeReferenceHelperDrawer
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user