Unload优化
This commit is contained in:
@@ -351,6 +351,7 @@ namespace Demo
|
|||||||
|
|
||||||
public PropertiesWindow.ItemEntry MyHierarchyItem;
|
public PropertiesWindow.ItemEntry MyHierarchyItem;
|
||||||
public static PropertiesWindow.ItemEntry AllScriptableObjectCounterHierarchyItem;
|
public static PropertiesWindow.ItemEntry AllScriptableObjectCounterHierarchyItem;
|
||||||
|
public static PropertiesWindow.ItemEntry ScriptParseingHierarchyItem;
|
||||||
|
|
||||||
public bool EnsureEnableScript()
|
public bool EnsureEnableScript()
|
||||||
{
|
{
|
||||||
@@ -496,6 +497,7 @@ namespace Demo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readonly object ParseScript2ExprObjectLocker = new();
|
||||||
public IEnumerator ParseScript2Expr(string script)
|
public IEnumerator ParseScript2Expr(string script)
|
||||||
{
|
{
|
||||||
IsParseScript2Expr = true;
|
IsParseScript2Expr = true;
|
||||||
@@ -523,9 +525,16 @@ namespace Demo
|
|||||||
new() { data = PrivateType.IInteractionJudgementLevelInstance.instance, type = typeof(PrivateType.IInteractionJudgementLevelInstance) } }
|
new() { data = PrivateType.IInteractionJudgementLevelInstance.instance, type = typeof(PrivateType.IInteractionJudgementLevelInstance) } }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (ScriptParseingHierarchyItem == null)
|
||||||
|
{
|
||||||
|
ScriptParseingHierarchyItem = HierarchyWindow.instance.CreateRootItemEntryWithBinders(ParseScript2ExprObjectLocker)[0];
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var ir in engine.RunAsync(script, importClass, variables).Yield())
|
foreach (var ir in engine.RunAsync(script, importClass, variables).Yield())
|
||||||
{
|
{
|
||||||
yield return ir;
|
yield return ir;
|
||||||
|
if (engine.context.CurrentRuntimePointer < engine.context.Sentences.Length)
|
||||||
|
ScriptParseingHierarchyItem.GetHierarchyItem().title = engine.context.CurrentSentence.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -640,35 +649,30 @@ namespace Demo
|
|||||||
if (EnsureEnableScript())
|
if (EnsureEnableScript())
|
||||||
{
|
{
|
||||||
this.name = "<Unloading>";
|
this.name = "<Unloading>";
|
||||||
try
|
foreach (var child in Childs)
|
||||||
{
|
{
|
||||||
foreach (var child in Childs)
|
ConventionUtility.StartCoroutine(child.UnloadScript());
|
||||||
{
|
|
||||||
yield return child.UnloadScript();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally
|
if (IsScriptApply)
|
||||||
{
|
{
|
||||||
this.isEnableScript = false;
|
// 清理各种状态
|
||||||
this.Parent = null;
|
IsScriptApply = false;
|
||||||
this.name = "<Unload>";
|
// 清理Cache
|
||||||
if (IsScriptApply)
|
//
|
||||||
{
|
// 减数
|
||||||
// 清理各种状态
|
AllScriptableObjectCounter--;
|
||||||
IsScriptApply = false;
|
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
||||||
// 清理Cache
|
|
||||||
//
|
|
||||||
// 减数
|
|
||||||
AllScriptableObjectCounter--;
|
|
||||||
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
|
||||||
}
|
|
||||||
if (MyHierarchyItem != null)
|
|
||||||
{
|
|
||||||
// 卸载UI
|
|
||||||
MyHierarchyItem.Release();
|
|
||||||
MyHierarchyItem = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (MyHierarchyItem != null)
|
||||||
|
{
|
||||||
|
// 卸载UI
|
||||||
|
MyHierarchyItem.Release();
|
||||||
|
MyHierarchyItem = null;
|
||||||
|
}
|
||||||
|
yield return new WaitUntil(() => Childs.Any(x => x.isEnableScript == false) == false);
|
||||||
|
this.isEnableScript = false;
|
||||||
|
this.Parent = null;
|
||||||
|
this.name = "<Unload>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user