Merge branch 'main' of http://www.liubai.site:3000/ninemine/Convention-Unity-Demo
This commit is contained in:
@@ -200,6 +200,24 @@ namespace Demo.Game
|
|||||||
var rootFileName = (string)MainConfig.FindItem("root");
|
var rootFileName = (string)MainConfig.FindItem("root");
|
||||||
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
|
var rootObject = new ToolFile(Path.Combine(content.RootSourceDir, rootFileName));
|
||||||
rootObject.MustExistsPath();
|
rootObject.MustExistsPath();
|
||||||
|
// 缓存MD5与重编译检查
|
||||||
|
var rootObjectDir = rootObject.GetParentDir();
|
||||||
|
ToolFile cacheDir = rootObjectDir | ".cache";
|
||||||
|
var projectHashFile = cacheDir | "projectHash.json";
|
||||||
|
Dictionary<string, string> projectHash = new();
|
||||||
|
bool isRecompile = true;
|
||||||
|
if(!!projectHashFile)
|
||||||
|
{
|
||||||
|
projectHash = projectHashFile.LoadAsJson<Dictionary<string, string>>();
|
||||||
|
foreach (var (file,md5) in projectHash)
|
||||||
|
{
|
||||||
|
if(new ToolFile(file).CalculateHash()!=md5)
|
||||||
|
{
|
||||||
|
isRecompile = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
||||||
MainObject = rootGameObject;
|
MainObject = rootGameObject;
|
||||||
rootGameObject.transform.SetParent(transform);
|
rootGameObject.transform.SetParent(transform);
|
||||||
@@ -210,6 +228,8 @@ namespace Demo.Game
|
|||||||
rootGameObject.SetContent(nameof(SongOffset), SongOffset);
|
rootGameObject.SetContent(nameof(SongOffset), SongOffset);
|
||||||
rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0);
|
rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0);
|
||||||
rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length);
|
rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length);
|
||||||
|
if (isRecompile||true)
|
||||||
|
{
|
||||||
static IEnumerator Foo(IEnumerator ir)
|
static IEnumerator Foo(IEnumerator ir)
|
||||||
{
|
{
|
||||||
Stack<IEnumerator> loadingTask = new();
|
Stack<IEnumerator> loadingTask = new();
|
||||||
@@ -251,14 +271,21 @@ namespace Demo.Game
|
|||||||
}
|
}
|
||||||
NDFS(rootGameObject);
|
NDFS(rootGameObject);
|
||||||
yield return new WaitUntil(() => applyDownCount == 0);
|
yield return new WaitUntil(() => applyDownCount == 0);
|
||||||
var rootObjectDir = rootObject.GetParentDir();
|
|
||||||
ToolFile projectHashFile = rootObjectDir | ".cache" | "projectHash.json";
|
|
||||||
Dictionary<string, string> projectHash = new();
|
|
||||||
foreach (var path in rootGameObject.LoadedScriptSet)
|
foreach (var path in rootGameObject.LoadedScriptSet)
|
||||||
{
|
{
|
||||||
projectHash.Add(path, new ToolFile(path).CalculateHash());
|
projectHash.Add(path, new ToolFile(path).CalculateHash());
|
||||||
}
|
}
|
||||||
projectHashFile.SaveAsJson(projectHash);
|
projectHashFile.SaveAsJson(projectHash);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var projectBinaryFile = cacheDir | "project.dat";
|
||||||
|
using var stream = new FileInfo(projectBinaryFile).OpenRead();
|
||||||
|
using var reader = new BinaryReader(stream);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
float loadRootObjectEndTime = Time.realtimeSinceStartup;
|
float loadRootObjectEndTime = Time.realtimeSinceStartup;
|
||||||
float loadRootObjectElapsed = (loadRootObjectEndTime - loadRootObjectStartTime) * 1000f;
|
float loadRootObjectElapsed = (loadRootObjectEndTime - loadRootObjectStartTime) * 1000f;
|
||||||
Debug.Log($"[GameInit] Load Root Object 耗时: {loadRootObjectElapsed:F2} ms", this);
|
Debug.Log($"[GameInit] Load Root Object 耗时: {loadRootObjectElapsed:F2} ms", this);
|
||||||
|
|||||||
Reference in New Issue
Block a user