73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
|
using UnityEngine;
|
|||
|
using Thousandto.CoreSDK;
|
|||
|
|
|||
|
namespace Thousandto.UpdateForm.Center
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 更新流程的启动类
|
|||
|
/// </summary>
|
|||
|
public static class LauncherUpdate
|
|||
|
{
|
|||
|
private static UpdateCenter _center;
|
|||
|
public static bool UseEditor = false;
|
|||
|
|
|||
|
public static MyRuntimePlatform RumtimePlatform = MyRuntimePlatform.None;
|
|||
|
//保存启动参数
|
|||
|
public static string[] StartupArgs;
|
|||
|
|
|||
|
public static void Start(string[] args)
|
|||
|
{
|
|||
|
StartupArgs = args;
|
|||
|
UnityEngine.Debug.Log(typeof(LauncherUpdate).ToString() + "->Start");
|
|||
|
|
|||
|
GameObject go = GameObject.Find("[UpdateRoot]");
|
|||
|
if (go != null)
|
|||
|
{
|
|||
|
if (_center == null)
|
|||
|
{
|
|||
|
_center = go.AddComponent<UpdateCenter>();
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
UnityEngine.Debug.LogError("没有找到启动节点[UpdateRoot]");
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public static void StartEditor(string[] arg)
|
|||
|
{
|
|||
|
UseEditor = true;
|
|||
|
Start(arg);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 从Launcher工程通过反射调用的函数,传递当前平台和是否跳过下载RemoteVersion.xml的标签
|
|||
|
/// </summary>
|
|||
|
/// <param name="targetPlatform"></param>
|
|||
|
/// <param name="skipDownRemoteVersion"></param>
|
|||
|
public static void SetDataFromLauncher(int targetPlatform)
|
|||
|
{
|
|||
|
RumtimePlatform = (MyRuntimePlatform)targetPlatform;
|
|||
|
SDKInitialize.SetRuntimePlatform(RumtimePlatform);
|
|||
|
UnityEngine.Debug.Log("From launcher, targetplatform=" + RumtimePlatform);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 网络是否可用
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public static bool IsNetworkEnable()
|
|||
|
{
|
|||
|
return Application.internetReachability != NetworkReachability.NotReachable;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 是否4G流量
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public static bool Is4G()
|
|||
|
{
|
|||
|
return Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|