diff --git a/Assets/VersionFlow/Builder/Builder.asset b/Assets/VersionFlow/Builder/Builder.asset index 3ab02a5..7695a84 100644 --- a/Assets/VersionFlow/Builder/Builder.asset +++ b/Assets/VersionFlow/Builder/Builder.asset @@ -14,8 +14,14 @@ MonoBehaviour: m_EditorClassIdentifier: vfSetting: {fileID: 11400000, guid: b304f98f44ccac546969282b7054a052, type: 2} debugGraphBackgroundStyle: {fileID: 7433441132597879392, guid: cbaf6570e48ba6248a61745f7f4473d4, type: 3} - uploaderClassName: VersionFlow.Editors.PatchUploader_LocalFileSystem - uploaderCfgJson: '{"UploadRoot":"../LocalPatchRoot"}' + uploaderClassName: VersionFlow.Editors.PatchUpLoader_AliOSS + UploaderCfgDict: + m_keys: + - VersionFlow.Editors.PatchUploader_LocalFileSystem + - VersionFlow.Editors.PatchUpLoader_AliOSS + m_values: + - '{"UploadRoot":"./LocalPatch"}' + - '{"BucketName":"asdad","UploadPath":"asdasd","accessKeyId":"asdasd","accessKeySecret":"dasdad","endPoint":"asdasd"}' Options: 288 Groups: - GroupName: Backpack diff --git a/Assets/VersionFlow/Runtime/SerializableDictionary.cs b/Assets/VersionFlow/Runtime/SerializableDictionary.cs new file mode 100644 index 0000000..477cf6b --- /dev/null +++ b/Assets/VersionFlow/Runtime/SerializableDictionary.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace VersionFlow.Runtime.Builder +{ + [Serializable] + public class SerializableDictionary : IDictionary + { + [SerializeField] + List m_keys = new List(); + [SerializeField] + List m_values = new List(); + + public void Add(KEY key, VALUE value) + { + if (m_keys.Contains(key)) + throw new Exception("Key Exist"); + + m_keys.Add(key); + m_values.Add(value); + } + + public bool ContainsKey(KEY key) + { + return m_keys.Contains(key); + } + + public bool Remove(KEY key) + { + if (!ContainsKey(key)) return false; + + var index = m_keys.IndexOf(key); + m_keys.RemoveAt(index); + m_values.RemoveAt(index); + + return true; + } + + public bool TryGetValue(KEY key, out VALUE value) + { + value = default; + var index = m_keys.IndexOf(key); + if (index == -1) return false; + + value = m_values[index]; + return true; + } + + public VALUE this[KEY key] + { + get + { + var index = m_keys.IndexOf(key); + if (index == -1) throw new KeyNotFoundException(); + return m_values[index]; + } + set + { + var index = m_keys.IndexOf(key); + if (index == -1) + { + Add(key, value); + } + else + { + m_keys[index] = key; + m_values[index] = value; + } + } + } + + public ICollection Keys => m_keys; + + public ICollection Values => m_values; + + public void Add(KeyValuePair item) + { + Add(item.Key, item.Value); + } + + public void Clear() + { + m_keys.Clear(); + m_values.Clear(); + } + + public bool Contains(KeyValuePair item) + { + if (!TryGetValue(item.Key, out VALUE value)) return false; + + return EqualityComparer.Default.Equals(value, item.Value); + } + + public void CopyTo(KeyValuePair[] array, int arrayIndex) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + + if (arrayIndex < 0 || arrayIndex >= array.Length) + throw new ArgumentOutOfRangeException(nameof(arrayIndex)); + + if (array.Length - arrayIndex < Count) + throw new ArgumentException("Destination array is not long enough to copy all the items in the collection. Check array index and length."); + + for (int i = 0; i < m_keys.Count; i++) + { + array[arrayIndex + i] = new KeyValuePair(m_keys[i], m_values[i]); + } + } + + public bool Remove(KeyValuePair item) + { + if (!Contains(item)) return false; + + return Remove(item.Key); + } + + public int Count => m_keys.Count; + + public bool IsReadOnly => false; + + public IEnumerator> GetEnumerator() + { + for (int i = 0; i < m_keys.Count; i++) + { + yield return new KeyValuePair(m_keys[i], m_values[i]); + } + } + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} \ No newline at end of file diff --git a/Assets/VersionFlow/Runtime/SerializableDictionary.cs.meta b/Assets/VersionFlow/Runtime/SerializableDictionary.cs.meta new file mode 100644 index 0000000..64fad64 --- /dev/null +++ b/Assets/VersionFlow/Runtime/SerializableDictionary.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fa315da522bc0f04599c822154d9d749 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: