diff --git a/Assets/Scripts/Pal3/GameResourceInitializer.cs b/Assets/Scripts/Pal3/GameResourceInitializer.cs index 42e14ecf..9c526bad 100644 --- a/Assets/Scripts/Pal3/GameResourceInitializer.cs +++ b/Assets/Scripts/Pal3/GameResourceInitializer.cs @@ -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(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; diff --git a/Assets/Scripts/Pal3/Renderer/LitMaterialFactory.cs b/Assets/Scripts/Pal3/Renderer/LitMaterialFactory.cs index 6d80f37d..0a3224f6 100644 --- a/Assets/Scripts/Pal3/Renderer/LitMaterialFactory.cs +++ b/Assets/Scripts/Pal3/Renderer/LitMaterialFactory.cs @@ -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; /// /// 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; diff --git a/Assets/Scripts/Pal3/Renderer/MaterialFactoryBase.cs b/Assets/Scripts/Pal3/Renderer/MaterialFactoryBase.cs index 2cd3cca2..d0ac8238 100644 --- a/Assets/Scripts/Pal3/Renderer/MaterialFactoryBase.cs +++ b/Assets/Scripts/Pal3/Renderer/MaterialFactoryBase.cs @@ -53,8 +53,6 @@ namespace Pal3.Renderer } } - protected virtual void ReturnToPool(Material material) - { - } + protected virtual void ReturnToPool(Material material) { } } } \ No newline at end of file diff --git a/Assets/Scripts/Pal3/Renderer/UnlitMaterialFactory.cs b/Assets/Scripts/Pal3/Renderer/UnlitMaterialFactory.cs index 9cdb1a77..5d3289df 100644 --- a/Assets/Scripts/Pal3/Renderer/UnlitMaterialFactory.cs +++ b/Assets/Scripts/Pal3/Renderer/UnlitMaterialFactory.cs @@ -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; /// /// 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."); } /// diff --git a/Assets/Scripts/Pal3/Scene/SceneManager.cs b/Assets/Scripts/Pal3/Scene/SceneManager.cs index c7dcb0a5..2f53781a 100644 --- a/Assets/Scripts/Pal3/Scene/SceneManager.cs +++ b/Assets/Scripts/Pal3/Scene/SceneManager.cs @@ -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