30 lines
879 B
C#
30 lines
879 B
C#
using System.IO;
|
||
using UnityEngine;
|
||
|
||
namespace XGame.MiniGame
|
||
{
|
||
// 小游戏 CDN 的平台段(与 LoadDll.sPlatform / CDN 目录命名一致),及平台相关的本地 AB 打开方式
|
||
public static class MiniGamePlatform
|
||
{
|
||
#if UNITY_ANDROID
|
||
public const string Name = "android";
|
||
#elif UNITY_IOS
|
||
public const string Name = "ios";
|
||
#elif UNITY_WEBGL
|
||
public const string Name = "webgl";
|
||
#else
|
||
public const string Name = "pc";
|
||
#endif
|
||
|
||
// WebGL 无同步文件系统 mmap,LoadFromFile 不可用 → 读字节走 LoadFromMemory;其余平台 LoadFromFile 更省内存
|
||
public static AssetBundle LoadAssetBundle(string localPath)
|
||
{
|
||
#if UNITY_WEBGL
|
||
return AssetBundle.LoadFromMemory(File.ReadAllBytes(localPath));
|
||
#else
|
||
return AssetBundle.LoadFromFile(localPath);
|
||
#endif
|
||
}
|
||
}
|
||
}
|