BS 0.2.0 UI控件同步 / EP Unity.1 Diagram版本下的附属增强提案
This commit is contained in:
60
Convention/[SO]/ScriptableObject.cs
Normal file
60
Convention/[SO]/ScriptableObject.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Convention
|
||||
{
|
||||
[CreateAssetMenu(fileName = "new Convention", menuName = "Convention/Convention", order = -1)]
|
||||
[Serializable, ArgPackage]
|
||||
public class ScriptableObject : UnityEngine.ScriptableObject
|
||||
{
|
||||
[return: ReturnNotNull]
|
||||
public string SymbolName()
|
||||
{
|
||||
return "Convention." + nameof(ScriptableObject);
|
||||
}
|
||||
|
||||
public SerializedDictionary<string, UnityEngine.Object> uobjects = new();
|
||||
public SerializedDictionary<string, string> symbols = new();
|
||||
public SerializedDictionary<string, float> values = new();
|
||||
|
||||
public T FindItem<T>(string key, T defaultValue = default)
|
||||
{
|
||||
var typen = typeof(T);
|
||||
if (typen.IsSubclassOf(typeof(UnityEngine.Object)))
|
||||
{
|
||||
if (uobjects.TryGetValue(key, out var uobj) && uobj is T uobj_r)
|
||||
return uobj_r;
|
||||
}
|
||||
else if (typen.IsSubclassOf(typeof(string)))
|
||||
{
|
||||
if (symbols.TryGetValue(key, out var str) && str is T str_r)
|
||||
return str_r;
|
||||
}
|
||||
else if (typen.IsSubclassOf(typeof(float)))
|
||||
{
|
||||
if (values.TryGetValue(key, out var fvalue) && fvalue is T fvalue_r)
|
||||
return fvalue_r;
|
||||
}
|
||||
else if (typen.IsSubclassOf(typeof(int)))
|
||||
{
|
||||
if (values.TryGetValue(key, out var ivalue) && ((int)ivalue) is T ivalue_r)
|
||||
return ivalue_r;
|
||||
}
|
||||
else if (typen.IsSubclassOf(typeof(bool)))
|
||||
{
|
||||
if (values.TryGetValue(key, out var bvalue) && (bvalue != 0) is T bvalue_r)
|
||||
return bvalue_r;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
uobjects.Clear();
|
||||
values.Clear();
|
||||
symbols.Clear();
|
||||
}
|
||||
}
|
||||
}
|
11
Convention/[SO]/ScriptableObject.cs.meta
Normal file
11
Convention/[SO]/ScriptableObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86ad14e0f9fcf5e4c97545f4c6ffc1b1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user