This commit is contained in:
CortexCore
2024-03-31 23:31:00 +08:00
parent e179d2eb53
commit b7b89ee71a
641 changed files with 31286 additions and 22134 deletions

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using UnityEngine;
namespace BITKit
{
[System.Serializable]
public record DataReference : References
{

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UIElements;
namespace BITKit
{
public sealed class DictionaryReferenceConfigAttribute : System.Attribute
{
public readonly int index;
public DictionaryReferenceConfigAttribute(int index)
{
this.index = index;
}
public DictionaryReferenceConfigAttribute(string keyword)
{
index=keyword.GetHashCode();
}
public DictionaryReferenceConfigAttribute()
{
index=0;
}
}
[Serializable]
public struct DictionaryReference : IReference
{
[SerializeField] private int index;
#if UNITY_EDITOR
[SerializeField,HideInInspector] private string keyword;
#endif
public string Get()
{
if (DictionaryReferenceScriptableObject.Dictionary.TryGetValue(index, out var value))
{
return value;
}
return "Not Found";
}
}
}

View File

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

View File

@@ -0,0 +1,70 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using AYellowpaper.SerializedCollections;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
namespace BITKit
{
public sealed class DictionaryReferenceScriptableObject : ScriptableObject
{
[SerializeField] private string mark;
[SerializeField] internal SerializedDictionary<int,string> dictionary;
public static DictionaryReferenceScriptableObject Singleton
{
get
{
if (_singleton == null)
{
_singleton = ScriptableObjectHelper.Get<DictionaryReferenceScriptableObject>();
}
return _singleton;
}
}
private static DictionaryReferenceScriptableObject _singleton;
public static IDictionary<int,string> Dictionary => Singleton.dictionary;
public static void Save()
{
#if UNITY_EDITOR
EditorUtility.SetDirty(Singleton);
#endif
}
public static void Add(string value)
{
#if UNITY_EDITOR
if (string.IsNullOrEmpty(value))
{
return;
}
var random = Random.Range(int.MinValue, int.MaxValue);
while (Dictionary.ContainsKey(random))
{
random = Random.Range(int.MinValue, int.MaxValue);
}
Singleton.dictionary.AddConflictAllowed(random,value);
Save();
#endif
}
public static void AddOrUpdate(int key, string value)
{
if (string.IsNullOrEmpty(value))
{
return;
}
if (Singleton.dictionary.TryAdd(key,value) is false)
{
Singleton.dictionary[key] = value;
}
Save();
}
}
}

View File

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

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit
{
[Serializable]
public sealed class TranslateReference:IReference
{
[SerializeReference, SubclassSelector] private IReference key;
public string Get()
{
return ScriptableObjectHelper.Get<TranslateSO>().GetAt(key.Value);
}
}
}

View File

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