1.全阶段异步加载与AB包预加载2.node加载无效的问题依然存在

This commit is contained in:
2025-10-06 16:09:52 +08:00
parent 8f8dfcbb64
commit 334f55a250
27 changed files with 1274 additions and 1220 deletions

View File

@@ -117,7 +117,7 @@ namespace Demo.Game
yield return null;
// Setup Game Rules
// Setup Game Rules (Main)
if (Editor.EditorController.instance.MainGameController == this)
{
ScriptableObject.FastScriptableObjectTypen = content.ScriptableObjectTypen;
@@ -126,11 +126,23 @@ namespace Demo.Game
SongOffset = (float)MainConfig.FindItem(nameof(SongOffset), SongOffset);
SetupSongDuration = GameContent.instance.SetupSongDuration;
SetSongCurrentTime = GameContent.instance.SetSongCurrentTime;
}
// Setup Game Rules
{
foreach (var ab in ((string)MainConfig.FindItem(nameof(AssetBundle), "")).Split(';'))
{
if (string.IsNullOrEmpty(ab))
continue;
StartCoroutine(AssetBundlesLoadHelper.LoadAssetBundleAsync(ab.Trim(), null));
}
IsHideTrackRender = (bool)MainConfig.FindItem(nameof(IsHideTrackRender), false);
IsAutoPlay = GameContent.instance.IsAutoPlay;
WhichOpenScript = (string)MainConfig.FindItem(nameof(WhichOpenScript), WhichOpenScript);
// Open Project
WhichOpenProject = (string)MainConfig.FindItem(nameof(WhichOpenProject), WhichOpenProject);
if (string.IsNullOrEmpty(WhichOpenProject) == false)
{
string path = string.Format($"{WhichOpenProject}", $"\"{Editor.EditorController.instance.PersistentDataPath}\"") ;
string path = string.Format($"{WhichOpenProject}", $"\"{Editor.EditorController.instance.PersistentDataPath}\"");
try
{
System.Diagnostics.Process.Start(path);
@@ -141,55 +153,51 @@ namespace Demo.Game
Debug.LogException(ex, this);
}
}
CurrentProjectDefaultFileStyle = content.CurrentProjectDefaultFileStyle;
}
MainConfig.SaveProperties();
yield return null;
// Load Root Object
{
while (MainConfig.Contains("root") == false)
{
IsHideTrackRender = (bool)MainConfig.FindItem(nameof(IsHideTrackRender), false);
IsAutoPlay = GameContent.instance.IsAutoPlay;
WhichOpenScript = (string)MainConfig.FindItem(nameof(WhichOpenScript), WhichOpenScript);
CurrentProjectDefaultFileStyle = content.CurrentProjectDefaultFileStyle;
}
yield return null;
MainConfig.SaveProperties();
// Load Root Object
{
while (MainConfig.Contains("root") == false)
string defaultRootPath = "root" + CurrentProjectDefaultFileStyle switch
{
string defaultRootPath = "root" + CurrentProjectDefaultFileStyle switch
ProjectDefaultFileStyle.PY => ".py",
_ => ".cpp"
};
if (content.IsCreateNewProject)
{
MainConfig["root"] = defaultRootPath;
if (MainConfig.CreateFile(defaultRootPath))
{
ProjectDefaultFileStyle.PY => ".py",
_ => ".cpp"
};
if (content.IsCreateNewProject)
{
MainConfig["root"] = defaultRootPath;
if (MainConfig.CreateFile(defaultRootPath))
{
MainConfig.SaveProperties();
break;
}
MainConfig.SaveProperties();
break;
}
Debug.LogError($"{nameof(defaultRootPath)} is cannt create or config's root property is not exist", this);
StartCoroutine(GameExit());
yield break;
}
var rootFileName = (string)MainConfig.FindItem("root");
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
rootObject.MustExistsPath();
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
rootGameObject.transform.SetParent(transform);
rootGameObject.ScriptName = rootObject.GetName(true);
rootGameObject.audioSystem = MainAudio;
rootGameObject.EnableScript(content.RootSourceDir, rootObject.GetFullPath(), this);
try
{
yield return rootGameObject.LoadScript(rootObject.LoadAsText());
}
finally
{
MainObject = rootGameObject;
}
Debug.LogError($"{nameof(defaultRootPath)} is cannt create or config's root property is not exist", this);
StartCoroutine(GameExit());
yield break;
}
var rootFileName = (string)MainConfig.FindItem("root");
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
rootObject.MustExistsPath();
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
rootGameObject.transform.SetParent(transform);
rootGameObject.ScriptName = rootObject.GetName(true);
rootGameObject.audioSystem = MainAudio;
rootGameObject.EnableScript(content.RootSourceDir, rootObject.GetFullPath(), this);
try
{
yield return rootGameObject.LoadScript(rootObject.LoadAsText());
}
finally
{
MainObject = rootGameObject;
}
}
}