From d2ab30e7a69bfe7efda63ae75812207377917bd3 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Sun, 30 Mar 2025 18:50:27 +0000
Subject: [PATCH] Merge branch 'Flexalon-UI-Layouts' into develop
---
Assets/Flexalon/Runtime/Core/FlexalonDict.cs | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/Assets/Flexalon/Runtime/Core/FlexalonDict.cs b/Assets/Flexalon/Runtime/Core/FlexalonDict.cs
new file mode 100644
index 0000000..1fd3713
--- /dev/null
+++ b/Assets/Flexalon/Runtime/Core/FlexalonDict.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Flexalon
+{
+ [Serializable]
+ internal class FlexalonDict<K, V> : ISerializationCallbackReceiver
+ {
+ private Dictionary<K, V> _dict = new Dictionary<K, V>();
+
+ [SerializeField]
+ private List<K> _keys = new List<K>();
+
+ [SerializeField]
+ private List<V> _values = new List<V>();
+
+ public void Add(K key, V value)
+ {
+ _dict.Add(key, value);
+ }
+
+ public bool TryGetValue(K key, out V value)
+ {
+ return _dict.TryGetValue(key, out value);
+ }
+
+ public void Clear()
+ {
+ _dict.Clear();
+ }
+
+ public int Count => _dict.Count;
+
+ public void OnBeforeSerialize()
+ {
+ _keys.Clear();
+ _values.Clear();
+
+ foreach (var kvp in _dict)
+ {
+ _keys.Add(kvp.Key);
+ _values.Add(kvp.Value);
+ }
+ }
+
+ public void OnAfterDeserialize()
+ {
+ _dict.Clear();
+ for (int i = 0; i < _keys.Count; i++)
+ {
+ _dict.Add(_keys[i], _values[i]);
+ }
+
+ _keys.Clear();
+ _values.Clear();
+ }
+ }
+}
\ No newline at end of file
--
Gitblit v1.10.0