Update
This commit is contained in:
ALEXTANG
2022-05-25 01:08:09 +08:00
parent 6a9cac0337
commit 9534994b6c
3 changed files with 63 additions and 31 deletions

View File

@@ -104,11 +104,15 @@ namespace TEngineCore
/// <returns></returns> /// <returns></returns>
internal string GetInnerVersion() internal string GetInnerVersion()
{ {
#if UNITY_ANDROID && !UNITY_EDITOR string innerPath = string.Empty;
var innerPath = Path.Combine(FileSystem.ResourceRootInStreamAsset, CONFIG); if (Application.platform == RuntimePlatform.Android)
#else {
var innerPath = $"file://{Path.Combine(FileSystem.ResourceRootInStreamAsset, CONFIG)}"; innerPath = Path.Combine(FileSystem.ResourceRootInStreamAsset, CONFIG);
#endif }
else
{
innerPath = $"file://{Path.Combine(FileSystem.ResourceRootInStreamAsset, CONFIG)}";
}
var www = UnityWebRequest.Get(innerPath); var www = UnityWebRequest.Get(innerPath);
var request = www.SendWebRequest(); var request = www.SendWebRequest();
while (!request.isDone) while (!request.isDone)

View File

@@ -117,15 +117,17 @@ namespace TEngineCore
public static Stream OpenRead(string filePath) public static Stream OpenRead(string filePath)
{ {
#if UNITY_ANDROID && !UNITY_EDITOR #if !UNITY_EDITOR
if (Application.platform == RuntimePlatform.Android)
{
byte[] bytes = ReadAllBytesFromOutOrInnerFolder(filePath); byte[] bytes = ReadAllBytesFromOutOrInnerFolder(filePath);
if (bytes != null) if (bytes != null)
return new MemoryStream(bytes); return new MemoryStream(bytes);
else else
return null; return null;
#else }
return File.OpenRead(filePath);
#endif #endif
return File.OpenRead(filePath);
} }
/// <summary> /// <summary>
@@ -137,8 +139,9 @@ namespace TEngineCore
{ {
if (string.IsNullOrEmpty(filePath)) if (string.IsNullOrEmpty(filePath))
return null; return null;
if (Application.platform == RuntimePlatform.Android)
#if UNITY_ANDROID && !UNITY_EDITOR {
#if !UNITY_EDITOR
//外部目录 //外部目录
if (filePath.StartsWith(Application.persistentDataPath)) if (filePath.StartsWith(Application.persistentDataPath))
{ {
@@ -148,10 +151,10 @@ namespace TEngineCore
{ {
return ReadAllBytesFromInnerFolder(filePath); return ReadAllBytesFromInnerFolder(filePath);
} }
#else
return ReadAllBytesFromOutFolder(filePath);
#endif #endif
} }
return ReadAllBytesFromOutFolder(filePath);
}
private static byte[] ReadAllBytesFromOutFolder(string filePath) private static byte[] ReadAllBytesFromOutFolder(string filePath)
{ {
@@ -165,9 +168,10 @@ namespace TEngineCore
private static byte[] ReadAllBytesFromInnerFolder(string filePath) private static byte[] ReadAllBytesFromInnerFolder(string filePath)
{ {
#if !UNITY_ANDROID || UNITY_EDITOR if (Application.platform != RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor)
{
filePath = $"file://{filePath}"; filePath = $"file://{filePath}";
#endif }
UnityWebRequest www = UnityWebRequest.Get(filePath); UnityWebRequest www = UnityWebRequest.Get(filePath);
UnityWebRequestAsyncOperation request = www.SendWebRequest(); UnityWebRequestAsyncOperation request = www.SendWebRequest();
while (!request.isDone) ; while (!request.isDone) ;
@@ -185,9 +189,10 @@ namespace TEngineCore
/// <returns></returns> /// <returns></returns>
private static string ReadTextFromInnerFolder(string filePath) private static string ReadTextFromInnerFolder(string filePath)
{ {
#if !UNITY_ANDROID || UNITY_EDITOR if (Application.platform != RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor)
{
filePath = $"file://{filePath}"; filePath = $"file://{filePath}";
#endif }
UnityWebRequest www = UnityWebRequest.Get(filePath); UnityWebRequest www = UnityWebRequest.Get(filePath);
UnityWebRequestAsyncOperation request = www.SendWebRequest(); UnityWebRequestAsyncOperation request = www.SendWebRequest();
while (!request.isDone) ; while (!request.isDone) ;

View File

@@ -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<TEngineLoginUI>();
GameClient.Instance.Connect("127.0.0.1", 54809, true);
}
}
}