推进修改
This commit is contained in:
@@ -206,29 +206,29 @@ namespace Demo.Game
|
||||
var projectHashFile = cacheDir | "projectHash.json";
|
||||
Dictionary<string, string> projectHash = new();
|
||||
bool isRecompile = true;
|
||||
if(!!projectHashFile)
|
||||
if (!!projectHashFile)
|
||||
{
|
||||
projectHash = projectHashFile.LoadAsJson<Dictionary<string, string>>();
|
||||
foreach (var (file,md5) in projectHash)
|
||||
foreach (var (file, md5) in projectHash)
|
||||
{
|
||||
if(new ToolFile(file).CalculateHash()!=md5)
|
||||
if (new ToolFile(file).CalculateHash() != md5)
|
||||
{
|
||||
isRecompile = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
||||
MainObject = rootGameObject;
|
||||
rootGameObject.transform.SetParent(transform);
|
||||
rootGameObject.ScriptName = rootObject.GetName(true);
|
||||
rootGameObject.audioSystem = MainAudio;
|
||||
rootGameObject.LoadedScriptSet.Add(rootObject);
|
||||
rootGameObject.EnableScript(content.RootSourceDir, this);
|
||||
rootGameObject.SetContent(nameof(SongOffset), SongOffset);
|
||||
rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0);
|
||||
rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length);
|
||||
if (isRecompile||true)
|
||||
var rootGameObject = new GameObject(rootObject.GetName(true)).AddComponent<RootObject>();
|
||||
MainObject = rootGameObject;
|
||||
rootGameObject.transform.SetParent(transform);
|
||||
rootGameObject.ScriptName = rootObject.GetName(true);
|
||||
rootGameObject.audioSystem = MainAudio;
|
||||
rootGameObject.LoadedScriptSet.Add(rootObject);
|
||||
rootGameObject.EnableScript(content.RootSourceDir, this);
|
||||
rootGameObject.SetContent(nameof(SongOffset), SongOffset);
|
||||
rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0);
|
||||
rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length);
|
||||
if (isRecompile || true)
|
||||
{
|
||||
static IEnumerator Foo(IEnumerator ir)
|
||||
{
|
||||
@@ -271,20 +271,26 @@ namespace Demo.Game
|
||||
}
|
||||
NDFS(rootGameObject);
|
||||
yield return new WaitUntil(() => applyDownCount == 0);
|
||||
projectHash.Clear();
|
||||
foreach (var path in rootGameObject.LoadedScriptSet)
|
||||
{
|
||||
projectHash.Add(path, new ToolFile(path).CalculateHash());
|
||||
}
|
||||
// 哈希缓存
|
||||
projectHashFile.SaveAsJson(projectHash);
|
||||
// 编译结果
|
||||
var projectBinaryFile = cacheDir | "project.dat";
|
||||
using var stream = new FileInfo(projectBinaryFile).OpenWrite();
|
||||
using var writer = new BinaryWriter(stream);
|
||||
rootGameObject.Config.Serialize(writer);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 加载
|
||||
var projectBinaryFile = cacheDir | "project.dat";
|
||||
using var stream = new FileInfo(projectBinaryFile).OpenRead();
|
||||
using var reader = new BinaryReader(stream);
|
||||
|
||||
|
||||
|
||||
rootGameObject.Config.Deserialize(reader);
|
||||
}
|
||||
float loadRootObjectEndTime = Time.realtimeSinceStartup;
|
||||
float loadRootObjectElapsed = (loadRootObjectEndTime - loadRootObjectStartTime) * 1000f;
|
||||
|
||||
Reference in New Issue
Block a user