mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Minor refactoring
This commit is contained in:
1 parent
ef2710f028
commit
f0efdfa67c
5 files changed
+24
-3
No files matched your search
@@ -165,6 +165,9 @@ namespace Pal3
|
||||
}
|
||||
}
|
||||
|
||||
loadingText.text = "正在初始化游戏资源...";
|
||||
yield return null; // Wait for next frame to make sure the text is updated
|
||||
|
||||
// Init TextureLoaderFactory
|
||||
TextureLoaderFactory textureLoaderFactory = new ();
|
||||
ServiceLocator.Instance.Register<ITextureLoaderFactory>(textureLoaderFactory);
|
||||
@@ -191,6 +194,9 @@ namespace Pal3
|
||||
|
||||
Debug.Log($"[{nameof(GameResourceInitializer)}] Game resources initialized.");
|
||||
|
||||
loadingText.text = "正在启动游戏...";
|
||||
yield return null; // Wait for next frame to make sure the text is updated
|
||||
|
||||
// Instantiate starting component
|
||||
GameObject startingGameObject = Instantiate(startingComponent, null);
|
||||
startingGameObject.name = startingComponent.name;
|
||||
|
||||
@@ -7,9 +7,11 @@ namespace Pal3.Renderer
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Core.GameBox;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
/// <summary>
|
||||
/// Lit material factory for generating materials
|
||||
@@ -74,6 +76,9 @@ namespace Pal3.Renderer
|
||||
|
||||
public void PreAllocateMaterialPool()
|
||||
{
|
||||
var timer = new Stopwatch();
|
||||
timer.Start();
|
||||
|
||||
for (var i = 0; i < OPAQUE_MATERIAL_POOL_SIZE; i++)
|
||||
{
|
||||
_opaqueMaterialPool.Push(new Material(_toonOpaqueMaterial)
|
||||
@@ -89,6 +94,9 @@ namespace Pal3.Renderer
|
||||
name = TRANSPARENT_MATERIAL_NAME
|
||||
});
|
||||
}
|
||||
|
||||
timer.Stop();
|
||||
Debug.Log($"[{nameof(LitMaterialFactory)}] Material pool allocated in {timer.ElapsedMilliseconds} ms.");
|
||||
}
|
||||
|
||||
public MaterialShaderType ShaderType => MaterialShaderType.Lit;
|
||||
|
||||
@@ -53,8 +53,6 @@ namespace Pal3.Renderer
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ReturnToPool(Material material)
|
||||
{
|
||||
}
|
||||
protected virtual void ReturnToPool(Material material) { }
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,11 @@
|
||||
namespace Pal3.Renderer
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using Core.GameBox;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
/// <summary>
|
||||
/// Unlit material factory for generating materials that have similar
|
||||
@@ -68,6 +70,9 @@ namespace Pal3.Renderer
|
||||
|
||||
public void PreAllocateMaterialPool()
|
||||
{
|
||||
var timer = new Stopwatch();
|
||||
timer.Start();
|
||||
|
||||
for (var i = 0; i < WATER_MATERIAL_POOL_SIZE; i++)
|
||||
{
|
||||
_waterMaterialPool.Push(new Material(_waterMaterial)
|
||||
@@ -99,6 +104,9 @@ namespace Pal3.Renderer
|
||||
name = OPAQUE_MATERIAL_NAME
|
||||
});
|
||||
}
|
||||
|
||||
timer.Stop();
|
||||
Debug.Log($"[{nameof(UnlitMaterialFactory)}] Material pool allocated in {timer.ElapsedMilliseconds} ms.");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -103,6 +103,7 @@ namespace Pal3.Scene
|
||||
? new ScenePostLoadingNotification(scnFile.SceneInfo, sceneScriptId)
|
||||
: new ScenePostLoadingNotification(scnFile.SceneInfo, ScriptConstants.InvalidScriptId));
|
||||
|
||||
timer.Stop();
|
||||
Debug.Log($"[{nameof(SceneManager)}] Scene loaded in {timer.Elapsed.TotalSeconds} seconds.");
|
||||
|
||||
// Also a good time to collect garbage
|
||||
|
||||
Reference in new issue
Block a user