using System;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace TEngine
{
///
/// 强制更新类型。
///
public enum UpdateStyle
{
///
/// 强制更新(不更新无法进入游戏。)
///
Force = 1,
///
/// 非强制(不更新可以进入游戏。)
///
Optional = 2,
}
///
/// 是否提示更新。
///
public enum UpdateNotice
{
///
/// 更新存在提示。
///
Notice = 1,
///
/// 更新非提示。
///
NoNotice = 2,
}
[CreateAssetMenu(menuName = "TEngine/UpdateSetting", fileName = "UpdateSetting")]
public class UpdateSetting : ScriptableObject
{
///
/// 项目名称。
///
[SerializeField]
private string projectName = "Demo";
public bool Enable
{
get
{
#if ENABLE_HYBRIDCLR
return true;
#else
return false;
#endif
}
}
[Header("Auto sync with [HybridCLRGlobalSettings]")]
public List HotUpdateAssemblies = new List() {"GameProto.dll", "GameLogic.dll" };
[Header("Need manual setting!")]
public List AOTMetaAssemblies = new List() { "mscorlib.dll", "System.dll", "System.Core.dll", "TEngine.Runtime.dll" ,"UniTask.dll", "YooAsset.dll"};
///
/// Dll of main business logic assembly
///
public string LogicMainDllName = "GameLogic.dll";
///
/// 程序集文本资产打包Asset后缀名
///
public string AssemblyTextAssetExtension = ".bytes";
///
/// 程序集文本资产资源目录
///
public string AssemblyTextAssetPath = "AssetRaw/DLL";
[Header("更新设置")]
public UpdateStyle UpdateStyle = UpdateStyle.Force;
public UpdateNotice UpdateNotice = UpdateNotice.Notice;
///
/// 资源服务器地址。
///
[SerializeField]
private string ResDownLoadPath = "http://127.0.0.1:8081";
///
/// 资源服务备用地址。
///
[SerializeField]
private string FallbackResDownLoadPath = "http://127.0.0.1:8082";
///
/// 获取资源下载路径。
///
public string GetResDownLoadPath()
{
return Path.Combine(ResDownLoadPath, projectName, GetPlatformName()).Replace("\\", "/");
}
///
/// 获取备用资源下载路径。
///
public string GetFallbackResDownLoadPath()
{
return Path.Combine(FallbackResDownLoadPath, projectName, GetPlatformName()).Replace("\\", "/");
}
///
/// 获取当前的平台名称。
///
/// 平台名称。
public static string GetPlatformName()
{
#if UNITY_ANDROID
return "Android";
#elif UNITY_IOS
return "IOS";
#elif UNITY_WEBGL
return "WebGL";
#else
switch (Application.platform)
{
case RuntimePlatform.WindowsEditor:
return "Windows64";
case RuntimePlatform.WindowsPlayer:
return "Windows64";
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
return "MacOS";
case RuntimePlatform.IPhonePlayer:
return "IOS";
case RuntimePlatform.Android:
return "Android";
case RuntimePlatform.WebGLPlayer:
return "WebGL";
case RuntimePlatform.PS5:
return "PS5";
default:
throw new NotSupportedException($"Platform '{Application.platform.ToString()}' is not supported.");
}
#endif
}
}
}