diff --git a/TEngineHotUpdate/src/TEngineCore/Core/GameConfig.cs b/TEngineHotUpdate/src/TEngineCore/Core/GameConfig.cs index 6dab2d24..e6c6c31b 100644 --- a/TEngineHotUpdate/src/TEngineCore/Core/GameConfig.cs +++ b/TEngineHotUpdate/src/TEngineCore/Core/GameConfig.cs @@ -104,11 +104,15 @@ namespace TEngineCore /// internal string GetInnerVersion() { -#if UNITY_ANDROID && !UNITY_EDITOR - var innerPath = Path.Combine(FileSystem.ResourceRootInStreamAsset, CONFIG); -#else - var innerPath = $"file://{Path.Combine(FileSystem.ResourceRootInStreamAsset, CONFIG)}"; -#endif + string innerPath = string.Empty; + if (Application.platform == RuntimePlatform.Android) + { + innerPath = Path.Combine(FileSystem.ResourceRootInStreamAsset, CONFIG); + } + else + { + innerPath = $"file://{Path.Combine(FileSystem.ResourceRootInStreamAsset, CONFIG)}"; + } var www = UnityWebRequest.Get(innerPath); var request = www.SendWebRequest(); while (!request.isDone) diff --git a/TEngineHotUpdate/src/TEngineCore/FileSystem/FileSystem.cs b/TEngineHotUpdate/src/TEngineCore/FileSystem/FileSystem.cs index f9cc3cde..ab05e97f 100644 --- a/TEngineHotUpdate/src/TEngineCore/FileSystem/FileSystem.cs +++ b/TEngineHotUpdate/src/TEngineCore/FileSystem/FileSystem.cs @@ -117,15 +117,17 @@ namespace TEngineCore public static Stream OpenRead(string filePath) { -#if UNITY_ANDROID && !UNITY_EDITOR - byte[] bytes = ReadAllBytesFromOutOrInnerFolder(filePath); - if (bytes != null) - return new MemoryStream(bytes); - else - return null; -#else - return File.OpenRead(filePath); +#if !UNITY_EDITOR + if (Application.platform == RuntimePlatform.Android) + { + byte[] bytes = ReadAllBytesFromOutOrInnerFolder(filePath); + if (bytes != null) + return new MemoryStream(bytes); + else + return null; + } #endif + return File.OpenRead(filePath); } /// @@ -137,20 +139,21 @@ namespace TEngineCore { if (string.IsNullOrEmpty(filePath)) return null; - -#if UNITY_ANDROID && !UNITY_EDITOR - //外部目录 - if (filePath.StartsWith(Application.persistentDataPath)) + if (Application.platform == RuntimePlatform.Android) { - return ReadAllBytesFromOutFolder(filePath); - } - else //内部目录 - { - return ReadAllBytesFromInnerFolder(filePath); - } -#else - return ReadAllBytesFromOutFolder(filePath); +#if !UNITY_EDITOR + //外部目录 + if (filePath.StartsWith(Application.persistentDataPath)) + { + return ReadAllBytesFromOutFolder(filePath); + } + else //内部目录 + { + return ReadAllBytesFromInnerFolder(filePath); + } #endif + } + return ReadAllBytesFromOutFolder(filePath); } private static byte[] ReadAllBytesFromOutFolder(string filePath) @@ -165,9 +168,10 @@ namespace TEngineCore private static byte[] ReadAllBytesFromInnerFolder(string filePath) { -#if !UNITY_ANDROID || UNITY_EDITOR - filePath = $"file://{filePath}"; -#endif + if (Application.platform != RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) + { + filePath = $"file://{filePath}"; + } UnityWebRequest www = UnityWebRequest.Get(filePath); UnityWebRequestAsyncOperation request = www.SendWebRequest(); while (!request.isDone) ; @@ -185,9 +189,10 @@ namespace TEngineCore /// private static string ReadTextFromInnerFolder(string filePath) { -#if !UNITY_ANDROID || UNITY_EDITOR - filePath = $"file://{filePath}"; -#endif + if (Application.platform != RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) + { + filePath = $"file://{filePath}"; + } UnityWebRequest www = UnityWebRequest.Get(filePath); UnityWebRequestAsyncOperation request = www.SendWebRequest(); while (!request.isDone) ; diff --git a/TEngineHotUpdate/src/TEngineDemo.cs b/TEngineHotUpdate/src/TEngineDemo.cs new file mode 100644 index 00000000..fab35b11 --- /dev/null +++ b/TEngineHotUpdate/src/TEngineDemo.cs @@ -0,0 +1,23 @@ +using TEngineCore.Net; + +namespace TEngineCore +{ + public class TEngineDemo : TEngine + { + protected override void RegisterAllSystem() + { + base.RegisterAllSystem(); + AddLogicSys(UISys.Instance); + AddLogicSys(DataCenterSys.Instance); + } + + protected override void StartGame() + { + UnityEngine.Debug.Log("你好呀华佗".ToColor(ColorUtils.White)); + + UISys.Mgr.ShowWindow(); + + GameClient.Instance.Connect("127.0.0.1", 54809, true); + } + } +} \ No newline at end of file