推进中, 解析存在错误
This commit is contained in:
@@ -109,9 +109,10 @@ namespace Demo
|
||||
/// </summary>
|
||||
public partial class ScriptableObject
|
||||
{
|
||||
public Dictionary<string, object> ScriptableObjectContents = new();
|
||||
public Dictionary<string, float> ScriptableObjectContents = new();
|
||||
|
||||
public object GetContent(string key)
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public float GetContent(string key)
|
||||
{
|
||||
if (ScriptableObjectContents.TryGetValue(key, out var result))
|
||||
{
|
||||
@@ -121,12 +122,14 @@ namespace Demo
|
||||
{
|
||||
return Parent.GetContent(key);
|
||||
}
|
||||
return null;
|
||||
throw new InvalidOperationException($"Key {key} is not find in contnet");
|
||||
}
|
||||
|
||||
public void SetContent(string key, object value)
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public float SetContent(string key, float value)
|
||||
{
|
||||
ScriptableObjectContents[key] = value;
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +302,7 @@ namespace Demo
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
[Convention.RScript.Variable.Attr.Method]
|
||||
public ScriptableObject NewSubScript([In] string type, [In] string name, [In] string path)
|
||||
public ScriptableObject LoadSubScript([In] string type, [In] string name, [In] string path)
|
||||
{
|
||||
// 判断类型是否合法
|
||||
if (DefaultInstantiate.GetScriptableObjectInstantiate().TryGetValue(type, out var creater) == false)
|
||||
@@ -390,6 +393,8 @@ namespace Demo
|
||||
RScriptImportClass importClass = new()
|
||||
{
|
||||
typeof(Mathf),
|
||||
typeof(UnityEngine.Random),
|
||||
typeof(MathExtension.EaseCurveType)
|
||||
};
|
||||
RScriptVariables variables = new()
|
||||
{
|
||||
@@ -403,7 +408,11 @@ namespace Demo
|
||||
return engine.RunAsync(script, importClass, variables);
|
||||
}
|
||||
|
||||
[Content] private bool IsEnableUpdate = false;
|
||||
[Content]
|
||||
public bool IsScriptApply
|
||||
{
|
||||
get; private set;
|
||||
} = false;
|
||||
|
||||
public enum TickType
|
||||
{
|
||||
@@ -416,7 +425,7 @@ namespace Demo
|
||||
[Content, SerializeField] private int ScriptUpdateCounter = 0;
|
||||
public void ScriptUpdate(float currentTime, float deltaTime, TickType tickType)
|
||||
{
|
||||
if (IsEnableUpdate == false)
|
||||
if (IsScriptApply == false)
|
||||
return;
|
||||
if (gameObject.activeInHierarchy == false)
|
||||
return;
|
||||
@@ -480,7 +489,7 @@ namespace Demo
|
||||
AllScriptableObjectCounter++;
|
||||
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
||||
}
|
||||
IsEnableUpdate = true;
|
||||
IsScriptApply = true;
|
||||
}
|
||||
|
||||
public virtual IEnumerator UnloadScript()
|
||||
@@ -497,22 +506,25 @@ namespace Demo
|
||||
}
|
||||
finally
|
||||
{
|
||||
// 清理各种状态
|
||||
IsEnableUpdate = false;
|
||||
this.isEnableScript = false;
|
||||
this.Parent = null;
|
||||
this.name = "<Unload>";
|
||||
if (IsScriptApply)
|
||||
{
|
||||
// 清理各种状态
|
||||
IsScriptApply = false;
|
||||
// 清理Cache
|
||||
//
|
||||
// 减数
|
||||
AllScriptableObjectCounter--;
|
||||
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
||||
}
|
||||
if (MyHierarchyItem != null)
|
||||
{
|
||||
// 卸载UI
|
||||
MyHierarchyItem.Release();
|
||||
MyHierarchyItem = null;
|
||||
}
|
||||
this.isEnableScript = false;
|
||||
this.Parent = null;
|
||||
this.name = "<Unload>";
|
||||
// 清理Cache
|
||||
//
|
||||
// 减数
|
||||
AllScriptableObjectCounter--;
|
||||
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user