From d0b2c8331f1d451cc0dfed3409e02f5fcc27cf99 Mon Sep 17 00:00:00 2001 From: Yurui <952870061@qq.com> Date: Mon, 28 Apr 2025 17:38:49 +0800 Subject: [PATCH] =?UTF-8?q?Main=20mono=E6=8B=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{Gameplay/Game => GameWrapper}/Main.cs | 25 +++++++++++++++---- .../Game => GameWrapper}/Main.cs.meta | 0 2 files changed, 20 insertions(+), 5 deletions(-) rename ProjectNLD/Assets/Code/Scripts/{Gameplay/Game => GameWrapper}/Main.cs (72%) rename ProjectNLD/Assets/Code/Scripts/{Gameplay/Game => GameWrapper}/Main.cs.meta (100%) diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Game/Main.cs b/ProjectNLD/Assets/Code/Scripts/GameWrapper/Main.cs similarity index 72% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/Game/Main.cs rename to ProjectNLD/Assets/Code/Scripts/GameWrapper/Main.cs index 473b9d4978e..772448e1b34 100644 --- a/ProjectNLD/Assets/Code/Scripts/Gameplay/Game/Main.cs +++ b/ProjectNLD/Assets/Code/Scripts/GameWrapper/Main.cs @@ -1,11 +1,15 @@ using PhxhSDK; using PhxhSDK.AOT; +using System; +using System.Reflection; using UnityEngine; namespace Gameplay { public class Main : SingletonMono
{ + private const string GAME_TYPE_NAME = "MyGame, GamePlay"; + private Game _game; public bool isInited @@ -14,16 +18,23 @@ namespace Gameplay private set; } - - private void _InitGame() { SDKManager.GetSingleton().InitEarly(); - _game = new MyGame(); + + Type type = Type.GetType(GAME_TYPE_NAME); + if (null == type) + { + Debug.LogError($"{GAME_TYPE_NAME} Type found"); + return; + } + + _game = Activator.CreateInstance(type) as Game; if (_game == null) { DebugUtil.LogError("PhxhSDK.Main: no game instance created"); } + SDKManager.GetSingleton().Init(); _game.Init(); _game.Start(); @@ -46,14 +57,18 @@ namespace Gameplay private void Update() { - if (!isInited) return; + if (!isInited) + return; + _game.Update(Time.deltaTime); SDKManager.Instance.Update(); } private void OnApplicationPause(bool pauseStatus) { - if (!isInited) return; + if (!isInited) + return; + _game.OnApplicationPause(pauseStatus); } diff --git a/ProjectNLD/Assets/Code/Scripts/Gameplay/Game/Main.cs.meta b/ProjectNLD/Assets/Code/Scripts/GameWrapper/Main.cs.meta similarity index 100% rename from ProjectNLD/Assets/Code/Scripts/Gameplay/Game/Main.cs.meta rename to ProjectNLD/Assets/Code/Scripts/GameWrapper/Main.cs.meta