This commit is contained in:
alienjack 2025-08-22 14:00:45 +08:00
parent d165b75f02
commit f3aa411e51
3 changed files with 156 additions and 2 deletions

View File

@ -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

View File

@ -0,0 +1,137 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace VersionFlow.Runtime.Builder
{
[Serializable]
public class SerializableDictionary<KEY, VALUE> : IDictionary<KEY, VALUE>
{
[SerializeField]
List<KEY> m_keys = new List<KEY>();
[SerializeField]
List<VALUE> m_values = new List<VALUE>();
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<KEY> Keys => m_keys;
public ICollection<VALUE> Values => m_values;
public void Add(KeyValuePair<KEY, VALUE> item)
{
Add(item.Key, item.Value);
}
public void Clear()
{
m_keys.Clear();
m_values.Clear();
}
public bool Contains(KeyValuePair<KEY, VALUE> item)
{
if (!TryGetValue(item.Key, out VALUE value)) return false;
return EqualityComparer<VALUE>.Default.Equals(value, item.Value);
}
public void CopyTo(KeyValuePair<KEY, VALUE>[] 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<KEY, VALUE>(m_keys[i], m_values[i]);
}
}
public bool Remove(KeyValuePair<KEY, VALUE> item)
{
if (!Contains(item)) return false;
return Remove(item.Key);
}
public int Count => m_keys.Count;
public bool IsReadOnly => false;
public IEnumerator<KeyValuePair<KEY, VALUE>> GetEnumerator()
{
for (int i = 0; i < m_keys.Count; i++)
{
yield return new KeyValuePair<KEY, VALUE>(m_keys[i], m_values[i]);
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fa315da522bc0f04599c822154d9d749
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: