| | |
| | | public class Launch : MonoBehaviour
|
| | | {
|
| | | static LaunchStage m_CurrentStage = LaunchStage.None;
|
| | | static public LaunchStage currentStage { get { return m_CurrentStage; } }
|
| | |
|
| | | static float m_Progress = 0f;
|
| | | static public float progress {
|
| | | get { return m_Progress; }
|
| | | set {
|
| | | if (m_Progress != value)
|
| | | {
|
| | | m_Progress = value;
|
| | |
|
| | | if (progressEvent != null)
|
| | | {
|
| | | progressEvent(m_CurrentStage, m_Progress);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public static event Action<LaunchStage, float> progressEvent;
|
| | | public static ProgressInfo progressInfo { get; private set; }
|
| | |
|
| | | private void Awake()
|
| | | {
|
| | | ResourcesPath.Instance.Init();
|
| | | SnxxzGame.Instance.gameObject.name = "__SnxxzGame__";
|
| | |
|
| | | Application.backgroundLoadingPriority = ThreadPriority.BelowNormal;
|
| | |
|
| | | Screen.sleepTimeout = SleepTimeout.NeverSleep;
|
| | |
|
| | | SDKUtility.Instance.Init();
|
| | |
| | | GlobalTimeEvent.Instance.Begin();
|
| | | }
|
| | |
|
| | | private byte m_Step = 0;
|
| | | float timer = 0f;
|
| | | float originalExpectTotalTime = 0f;
|
| | | float expectTotalTime = 0f;
|
| | | public float totalTime {
|
| | | get {
|
| | | return Mathf.Lerp(originalExpectTotalTime, expectTotalTime, Mathf.Clamp01(timer / expectTotalTime));
|
| | | }
|
| | | }
|
| | |
|
| | | Queue<LaunchTask> tasks = new Queue<LaunchTask>();
|
| | | LaunchTask currentTask = null;
|
| | | bool launchComplete = false;
|
| | |
|
| | | void Start()
|
| | | {
|
| | | m_Step = 0;
|
| | | Application.backgroundLoadingPriority = ThreadPriority.High;
|
| | | SoundPlayer.Instance.PlayLoginMusic();
|
| | | Config.Instance.PreLoadConfigs();
|
| | |
|
| | | WindowCenter.Instance.OpenFromLocal<LaunchWin>();
|
| | | SystemSetting.Instance.LetFPSUnLimit();
|
| | | Config.Instance.RegisterGlobalEvent();
|
| | | PackageRegedit.Init();
|
| | | DebugUtility.Instance.CreateDebugRoot();
|
| | |
|
| | | StartCoroutine(Co_Lanuch());
|
| | | WindowCenter.Instance.OpenFromLocal<LaunchWin>();
|
| | |
|
| | | var sdkInitedTask = new SDKInitedTask();
|
| | | var assetCopyTask = new AssetCopyTask();
|
| | | var assetDecompressTask = new AssetDecompressTask();
|
| | | var getVersionInfoTask = new GetVersionInfoTask();
|
| | | var checkAssetValidTask = new CheckAssetValidTask();
|
| | | var downLoadAssetTask = new DownLoadAssetTask();
|
| | | var assetBundleInitTask = new AssetBundleInitTask();
|
| | | var configInitTask = new ConfigInitTask();
|
| | | var launchFadeOutTask = new LaunchFadeOutTask();
|
| | |
|
| | | #if !UNITY_EDITOR
|
| | | tasks.Enqueue(sdkInitedTask);
|
| | | #endif
|
| | |
|
| | | #if UNITY_ANDROID
|
| | | #if !UNITY_EDITOR
|
| | | tasks.Enqueue(assetCopyTask);
|
| | | tasks.Enqueue(assetDecompressTask);
|
| | | #endif
|
| | | tasks.Enqueue(getVersionInfoTask);
|
| | | #endif
|
| | |
|
| | | #if UNITY_IOS
|
| | | tasks.Enqueue(getVersionInfoTask);
|
| | | tasks.Enqueue(assetCopyTask);
|
| | | #endif
|
| | |
|
| | | tasks.Enqueue(checkAssetValidTask);
|
| | | tasks.Enqueue(downLoadAssetTask);
|
| | | tasks.Enqueue(assetBundleInitTask);
|
| | | tasks.Enqueue(configInitTask);
|
| | | tasks.Enqueue(launchFadeOutTask);
|
| | |
|
| | | CalculateExpectTotalTime();
|
| | | originalExpectTotalTime = expectTotalTime;
|
| | | }
|
| | |
|
| | | void Update()
|
| | | {
|
| | | if (m_Step == 1)
|
| | | timer += Time.deltaTime;
|
| | |
|
| | | if (!launchComplete)
|
| | | {
|
| | | ServerListCenter.Instance.RequestJumpUrl();
|
| | | m_Step = 2;
|
| | | if (currentTask == null)
|
| | | {
|
| | | if (tasks.Count > 0)
|
| | | {
|
| | | currentTask = tasks.Dequeue();
|
| | | currentTask.Begin();
|
| | | }
|
| | | else
|
| | | {
|
| | | launchComplete = true;
|
| | | }
|
| | | }
|
| | |
|
| | | if (currentTask != null)
|
| | | {
|
| | | currentTask.Update();
|
| | | }
|
| | |
|
| | | if (currentTask != null && currentTask.done)
|
| | | {
|
| | | currentTask.End();
|
| | | CalculateExpectTotalTime();
|
| | | currentTask = null;
|
| | | }
|
| | |
|
| | | var progress = Mathf.Lerp(progressInfo.totalProgress, timer / totalTime, 0.5f);
|
| | |
|
| | | var partProgress = 0f;
|
| | | if (currentTask == null)
|
| | | {
|
| | | partProgress = 0f;
|
| | | }
|
| | | else
|
| | | {
|
| | | var temp = currentTask.timer / Mathf.Min(1f, currentTask.duration);
|
| | | partProgress = temp - (int)temp;
|
| | | }
|
| | |
|
| | | progressInfo = new ProgressInfo(m_CurrentStage, progress, partProgress);
|
| | | }
|
| | |
|
| | | if (launchComplete)
|
| | | {
|
| | | Debug.LogFormat("启动耗时:{0}", timer);
|
| | | progressInfo = new ProgressInfo(m_CurrentStage, 1f, 1f);
|
| | | this.enabled = false;
|
| | | StageManager.Instance.LoadLoginStage();
|
| | | }
|
| | | }
|
| | |
|
| | | IEnumerator Co_Lanuch()
|
| | | void CalculateExpectTotalTime()
|
| | | {
|
| | | var startTime = Time.time;
|
| | | var progressBuf = progress;
|
| | | var timer = 0f;
|
| | | var duration = 1f;
|
| | |
|
| | | #if !UNITY_EDITOR
|
| | | while (!SDKUtility.Instance.InitFinished)
|
| | | var time = timer;
|
| | | foreach (var item in tasks)
|
| | | {
|
| | | time += item.expectTime;
|
| | | }
|
| | |
|
| | | expectTotalTime = time;
|
| | | }
|
| | |
|
| | | public enum LaunchStage
|
| | | {
|
| | | None = 0,
|
| | | SDKInit = 1,
|
| | | AssetCopy = 2,
|
| | | ClientVersion = 3,
|
| | | CheckAsset = 4,
|
| | | DownLoad = 5,
|
| | | AssetBundleInit = 6,
|
| | | ConfigInit = 7,
|
| | | Complete = 8,
|
| | | }
|
| | |
|
| | | public abstract class LaunchTask
|
| | | {
|
| | | public float timer { get; protected set; }
|
| | | public float duration { get; protected set; }
|
| | | bool exceptionReported = false;
|
| | |
|
| | | public bool done { get; protected set; }
|
| | | public float progress { get; protected set; }
|
| | | public virtual float expectTime { get; protected set; }
|
| | |
|
| | | public abstract void Begin();
|
| | | public abstract void Update();
|
| | | public abstract void End();
|
| | |
|
| | | public void ExceptionReport()
|
| | | {
|
| | | if (!exceptionReported && timer > 15f && !done)
|
| | | {
|
| | | var content = string.Format("任务:{0};网络状态:{1}", this.GetType().Name, Application.internetReachability);
|
| | | ExceptionCatcher.ReportException("游戏启动执行失败!", content);
|
| | | exceptionReported = true;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public class SDKInitedTask : LaunchTask
|
| | | {
|
| | | public override float expectTime {
|
| | | get { return LocalSave.GetFloat("SDKInitedTask_ExpectTime", 0.5f); }
|
| | | protected set { LocalSave.SetFloat("SDKInitedTask_ExpectTime", value); }
|
| | | }
|
| | |
|
| | | public override void Begin()
|
| | | {
|
| | | m_CurrentStage = LaunchStage.SDKInit;
|
| | | duration = Mathf.Max(0.1f, expectTime);
|
| | | }
|
| | |
|
| | | public override void End()
|
| | | {
|
| | | expectTime = timer;
|
| | | DebugEx.LogFormat("{0}执行时长:{1};", this.GetType().Name, timer);
|
| | |
|
| | | OperationLogCollect.Instance.RecordLauchEvent(1);
|
| | | OperationLogCollect.Instance.RecordEvent(1);
|
| | |
|
| | | var cpu = 2;
|
| | | var memory = 2048;
|
| | | DeviceUtility.GetCpuAndMemory(out cpu, out memory);
|
| | | DebugEx.LogFormat("获得机器信息:cpu {0}----内存 {1}", cpu, memory);
|
| | | GameNotice.OpenGameNotice();
|
| | | }
|
| | |
|
| | | public override void Update()
|
| | | {
|
| | | if (done)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | timer += Time.deltaTime;
|
| | | progress = Mathf.Clamp(progressBuf + timer / duration * 0.1f, progressBuf, progressBuf + 0.1f);
|
| | | yield return null;
|
| | | if (SDKUtility.Instance.InitFinished)
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = false;
|
| | | progress = timer / duration;
|
| | | }
|
| | |
|
| | | ExceptionReport();
|
| | | }
|
| | | #endif
|
| | | }
|
| | |
|
| | | m_Step = 1;
|
| | | var cpu = 2;
|
| | | var memory = 2048;
|
| | | DeviceUtility.GetCpuAndMemory(out cpu, out memory);
|
| | | public class AssetCopyTask : LaunchTask
|
| | | {
|
| | | int completedCount = 0;
|
| | | int totalCount = 1;
|
| | | List<FileInfo> copyTasks = new List<FileInfo>();
|
| | |
|
| | | DebugEx.LogFormat("获得机器信息:cpu {0}----内存 {1}", cpu, memory);
|
| | | public override float expectTime {
|
| | | get { return LocalSave.GetFloat("AssetCopyTask_ExpectTime", 20f); }
|
| | | protected set { LocalSave.SetFloat("AssetCopyTask_ExpectTime", value); }
|
| | | }
|
| | |
|
| | | OperationLogCollect.Instance.RecordLauchEvent(1);
|
| | | OperationLogCollect.Instance.RecordEvent(1);
|
| | | SystemSetting.Instance.LetFPSUnLimit();
|
| | | Config.Instance.RegisterGlobalEvent();
|
| | |
|
| | | PackageRegedit.Init();
|
| | | GameNotice.OpenGameNotice();
|
| | |
|
| | | #if UNITY_ANDROID && !UNITY_EDITOR
|
| | | switch (VersionConfig.Get().assetAccess)
|
| | | public override void Begin()
|
| | | {
|
| | | case InstalledAsset.FullAsset:
|
| | | case InstalledAsset.HalfAsset:
|
| | | case InstalledAsset.IngoreDownLoad:
|
| | | progressBuf = progress;
|
| | | timer = 0f;
|
| | | duration = 30f;
|
| | | m_CurrentStage = LaunchStage.AssetCopy;
|
| | | duration = Mathf.Max(0.1f, expectTime);
|
| | |
|
| | | if (!SDKUtility.Instance.AssetCopyFinished)
|
| | | {
|
| | | m_CurrentStage = LaunchStage.AssetCopy;
|
| | | SDKUtility.Instance.CopyAsset();
|
| | | while (!SDKUtility.Instance.AssetCopyFinished)
|
| | | {
|
| | | timer += Time.deltaTime;
|
| | | progress = Mathf.Clamp(progressBuf + timer / duration * 0.7f, progressBuf, progressBuf + 0.7f);
|
| | | yield return null;
|
| | | }
|
| | | }
|
| | |
|
| | | if (!AssetDeCompressTask.assetDeCompressCompleted)
|
| | | {
|
| | | progressBuf = progress;
|
| | | var decompressProgress = AssetDeCompressTask.DecompressAync(ResourcesPath.Instance.ExternalStorePath);
|
| | | while (!decompressProgress.done)
|
| | | {
|
| | | progress = progressBuf + decompressProgress.progress * 0.2f;
|
| | | yield return null;
|
| | | }
|
| | |
|
| | | AssetDeCompressTask.assetDeCompressVersion = VersionConfig.Get().version;
|
| | |
|
| | | progressBuf = progress;
|
| | | timer = 0f;
|
| | | while (timer < 2f)
|
| | | {
|
| | | timer += Time.deltaTime;
|
| | | progress = progressBuf + timer * 0.5f * 0.1f;
|
| | | yield return null;
|
| | | }
|
| | |
|
| | | AssetDeCompressTask.Delete7zFiles(ResourcesPath.Instance.ExternalStorePath);
|
| | | }
|
| | | break;
|
| | | case InstalledAsset.NullAsset:
|
| | | progress = 1f;
|
| | | break;
|
| | | }
|
| | |
|
| | | #endif
|
| | |
|
| | | progress = 0f;
|
| | | #if UNITY_ANDROID
|
| | | m_CurrentStage = LaunchStage.ClientVersion;
|
| | | if (!Application.isEditor || InGameDownTestUtility.enable)
|
| | | {
|
| | | VersionUtility.Instance.RequestVersionCheck();
|
| | | progressBuf = progress;
|
| | | timer = 0f;
|
| | | duration = 1f;
|
| | |
|
| | | while (!VersionUtility.Instance.completed)
|
| | | {
|
| | | timer += Time.deltaTime;
|
| | | progress = Mathf.Clamp(progressBuf + timer / duration * 0.1f, progressBuf, progressBuf + 0.1f);
|
| | | yield return null;
|
| | | }
|
| | | }
|
| | | #endif
|
| | |
|
| | | #if UNITY_IOS
|
| | | if (!VersionUtility.Instance.InIosAuditTime())
|
| | | {
|
| | | m_CurrentStage = LaunchStage.ClientVersion;
|
| | | if (!Application.isEditor || InGameDownTestUtility.enable)
|
| | | {
|
| | | VersionUtility.Instance.RequestVersionCheck();
|
| | | progressBuf = progress;
|
| | | timer = 0f;
|
| | | duration = 1f;
|
| | |
|
| | | while (!VersionUtility.Instance.completed)
|
| | | {
|
| | | timer += Time.deltaTime;
|
| | | progress = Mathf.Clamp(progressBuf + timer / duration * 0.1f, progressBuf, progressBuf + 0.1f);
|
| | | yield return null;
|
| | | }
|
| | | }
|
| | | }
|
| | | #endif
|
| | |
|
| | | #if UNITY_IOS && !UNITY_EDITOR
|
| | |
|
| | | if (VersionUtility.Instance.versionInfo != null && VersionUtility.Instance.versionInfo.downAsset == 1)
|
| | | {
|
| | | switch (VersionConfig.Get().assetAccess)
|
| | | {
|
| | | case InstalledAsset.FullAsset:
|
| | |
| | | case InstalledAsset.IngoreDownLoad:
|
| | | if (!SDKUtility.Instance.AssetCopyFinished)
|
| | | {
|
| | | m_CurrentStage = LaunchStage.AssetCopy;
|
| | | progressBuf = progress;
|
| | |
|
| | | var allFiles = new List<FileInfo>();
|
| | | FileExtersion.GetAllDirectoryFileInfos(ResourcesPath.Instance.StreamingAssetPath, allFiles);
|
| | |
|
| | | var count = allFiles.Count;
|
| | | var index = 0;
|
| | | while (index < count)
|
| | | {
|
| | | try
|
| | | {
|
| | | var fileInfo = allFiles[index];
|
| | | var destPath = fileInfo.FullName.Replace(ResourcesPath.Instance.StreamingAssetPath, ResourcesPath.Instance.ExternalStorePath);
|
| | | if (File.Exists(destPath))
|
| | | {
|
| | | index++;
|
| | | continue;
|
| | | }
|
| | |
|
| | | var destDirectoryName = Path.GetDirectoryName(destPath);
|
| | | if (!Directory.Exists(destDirectoryName))
|
| | | {
|
| | | Directory.CreateDirectory(destDirectoryName);
|
| | | }
|
| | |
|
| | | DebugEx.LogFormat("拷贝文件:{0}", fileInfo.Name);
|
| | | File.Copy(fileInfo.FullName, destPath, true);
|
| | | index++;
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | DebugEx.Log(ex);
|
| | | }
|
| | | finally
|
| | | {
|
| | | progress = Mathf.Clamp(progressBuf + ((float)index / count) * 0.3f, progressBuf, progressBuf + 0.3f);
|
| | | }
|
| | |
|
| | | yield return null;
|
| | | }
|
| | |
|
| | | LocalSave.SetString("AssetCopyCompleted_IOS", VersionConfig.Get().version);
|
| | | SDKUtility.Instance.CopyAsset();
|
| | | done = false;
|
| | | progress = 0f;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | break;
|
| | | case InstalledAsset.NullAsset:
|
| | | progress = 0.1f;
|
| | | done = true;
|
| | | break;
|
| | | }
|
| | | #endif
|
| | |
|
| | | #if UNITY_IOS
|
| | | if (VersionUtility.Instance.versionInfo != null && VersionUtility.Instance.versionInfo.downAsset == 1)
|
| | | {
|
| | | switch (VersionConfig.Get().assetAccess)
|
| | | {
|
| | | case InstalledAsset.FullAsset:
|
| | | case InstalledAsset.HalfAsset:
|
| | | case InstalledAsset.IngoreDownLoad:
|
| | | if (!SDKUtility.Instance.AssetCopyFinished)
|
| | | {
|
| | | copyTasks = new List<FileInfo>();
|
| | | FileExtersion.GetAllDirectoryFileInfos(ResourcesPath.Instance.StreamingAssetPath, copyTasks);
|
| | |
|
| | | for (var i = copyTasks.Count - 1; i >= 0; i--)
|
| | | {
|
| | | var fileInfo = copyTasks[i];
|
| | | var destPath = fileInfo.FullName.Replace(ResourcesPath.Instance.StreamingAssetPath, ResourcesPath.Instance.ExternalStorePath);
|
| | | if (File.Exists(destPath))
|
| | | {
|
| | | copyTasks.RemoveAt(i);
|
| | | }
|
| | | }
|
| | |
|
| | | completedCount = 0;
|
| | | totalCount = copyTasks.Count;
|
| | | }
|
| | |
|
| | | if (totalCount > 0)
|
| | | {
|
| | | done = false;
|
| | | progress = 0f;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | break;
|
| | | case InstalledAsset.NullAsset:
|
| | | done = true;
|
| | | break;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | #endif
|
| | |
|
| | | }
|
| | |
|
| | | public override void End()
|
| | | {
|
| | | expectTime = timer;
|
| | | DebugEx.LogFormat("{0}执行时长:{1};", this.GetType().Name, timer);
|
| | | #if UNITY_IOS
|
| | | LocalSave.SetString("AssetCopyCompleted_IOS", VersionConfig.Get().version);
|
| | | #endif
|
| | | }
|
| | |
|
| | | public override void Update()
|
| | | {
|
| | | if (done)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | timer += Time.deltaTime;
|
| | | #if UNITY_ANDROID
|
| | | if (!SDKUtility.Instance.AssetCopyFinished)
|
| | | {
|
| | | done = false;
|
| | | progress = timer / duration;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | #endif
|
| | |
|
| | | #if UNITY_IOS
|
| | | if (totalCount > 0)
|
| | | {
|
| | | if (completedCount < totalCount)
|
| | | {
|
| | | var fileInfo = copyTasks[0];
|
| | | var destPath = fileInfo.FullName.Replace(ResourcesPath.Instance.StreamingAssetPath, ResourcesPath.Instance.ExternalStorePath);
|
| | | var destDirectoryName = Path.GetDirectoryName(destPath);
|
| | | if (!Directory.Exists(destDirectoryName))
|
| | | {
|
| | | Directory.CreateDirectory(destDirectoryName);
|
| | | }
|
| | |
|
| | | DebugEx.LogFormat("拷贝文件:{0}", fileInfo.Name);
|
| | | File.Copy(fileInfo.FullName, destPath, true);
|
| | | copyTasks.RemoveAt(0);
|
| | | completedCount++;
|
| | |
|
| | | done = false;
|
| | | progress = (float)completedCount / totalCount;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | }
|
| | |
|
| | | #endif
|
| | | ExceptionReport();
|
| | | }
|
| | | }
|
| | |
|
| | | OperationLogCollect.Instance.RecordLauchEvent(2);
|
| | | OperationLogCollect.Instance.RecordEvent(2);
|
| | | public class AssetDecompressTask : LaunchTask
|
| | | {
|
| | | public override float expectTime {
|
| | | get { return LocalSave.GetFloat("AssetDecompressTask_ExpectTime", 5f); }
|
| | | protected set { LocalSave.SetFloat("AssetDecompressTask_ExpectTime", value); }
|
| | | }
|
| | |
|
| | | if (VersionUtility.Instance.NeedDownAsset())
|
| | | AssetDeCompressTask.DecompressProgress deCompressProgress = null;
|
| | | float waitTimer = 0f;
|
| | |
|
| | | public override void Begin()
|
| | | {
|
| | | m_CurrentStage = LaunchStage.AssetCopy;
|
| | | duration = Mathf.Max(0.1f, expectTime);
|
| | |
|
| | | if (!AssetDeCompressTask.assetDeCompressCompleted)
|
| | | {
|
| | | deCompressProgress = AssetDeCompressTask.DecompressAync(ResourcesPath.Instance.ExternalStorePath);
|
| | | done = false;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | }
|
| | |
|
| | | public override void End()
|
| | | {
|
| | | AssetDeCompressTask.assetDeCompressVersion = VersionConfig.Get().version;
|
| | | AssetDeCompressTask.Delete7zFiles(ResourcesPath.Instance.ExternalStorePath);
|
| | | }
|
| | |
|
| | | public override void Update()
|
| | | {
|
| | | if (done)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | timer += Time.deltaTime;
|
| | | progress = timer / duration;
|
| | | if (deCompressProgress == null || deCompressProgress.done)
|
| | | {
|
| | | waitTimer += Time.deltaTime;
|
| | | if (waitTimer > 2f)
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public class GetVersionInfoTask : LaunchTask
|
| | | {
|
| | | public override float expectTime {
|
| | | get { return LocalSave.GetFloat("GetVersionInfoTask_ExpectTime", 1f); }
|
| | | protected set { LocalSave.SetFloat("GetVersionInfoTask_ExpectTime", value); }
|
| | | }
|
| | |
|
| | | public override void Begin()
|
| | | {
|
| | | m_CurrentStage = LaunchStage.ClientVersion;
|
| | | duration = expectTime;
|
| | |
|
| | | #if UNITY_ANDROID
|
| | | if (InGameDownTestUtility.enable || !Application.isEditor)
|
| | | {
|
| | | VersionUtility.Instance.RequestVersionCheck();
|
| | | done = false;
|
| | | progress = 0f;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | #endif
|
| | |
|
| | | #if UNITY_IOS
|
| | | if (!VersionUtility.Instance.InIosAuditTime())
|
| | | {
|
| | | VersionUtility.Instance.RequestVersionCheck();
|
| | | done = false;
|
| | | progress = 0f;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | #endif
|
| | | }
|
| | |
|
| | | public override void End()
|
| | | {
|
| | | expectTime = timer;
|
| | | DebugEx.LogFormat("{0}执行时长:{1};", this.GetType().Name, timer);
|
| | | }
|
| | |
|
| | | public override void Update()
|
| | | {
|
| | | if (done)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | timer += Time.deltaTime;
|
| | | if (!VersionUtility.Instance.completed)
|
| | | {
|
| | | done = false;
|
| | | progress = timer / expectTime;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | |
|
| | | ExceptionReport();
|
| | | }
|
| | | }
|
| | |
|
| | | public class CheckAssetValidTask : LaunchTask
|
| | | {
|
| | | public override float expectTime {
|
| | | get { return LocalSave.GetFloat("CheckAssetValidTask_ExpectTime", 3f); }
|
| | | protected set { LocalSave.SetFloat("CheckAssetValidTask_ExpectTime", value); }
|
| | | }
|
| | |
|
| | | public override void Begin()
|
| | | {
|
| | | m_CurrentStage = LaunchStage.CheckAsset;
|
| | | duration = Mathf.Max(0.1f, expectTime);
|
| | |
|
| | | ServerListCenter.Instance.RequestJumpUrl();
|
| | | OperationLogCollect.Instance.RecordLauchEvent(2);
|
| | | OperationLogCollect.Instance.RecordEvent(2);
|
| | |
|
| | | if (VersionUtility.Instance.NeedDownAsset())
|
| | | {
|
| | | AssetVersionUtility.GetAssetVersionFile();
|
| | | done = false;
|
| | | progress = 0f;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | }
|
| | |
|
| | | public override void End()
|
| | | {
|
| | | expectTime = timer;
|
| | | DebugEx.LogFormat("{0}执行时长:{1};", this.GetType().Name, timer);
|
| | | }
|
| | |
|
| | | public override void Update()
|
| | | {
|
| | | if (done)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | timer += Time.deltaTime;
|
| | | if (!AssetVersionUtility.checkAssetCompleted)
|
| | | {
|
| | | done = false;
|
| | | progress = timer / expectTime;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | |
|
| | | ExceptionReport();
|
| | | }
|
| | | }
|
| | |
|
| | | public class DownLoadAssetTask : LaunchTask
|
| | | {
|
| | | public override float expectTime {
|
| | | get { return LocalSave.GetFloat("DownLoadAssetTask_ExpectTime", 3f); }
|
| | | protected set { LocalSave.SetFloat("DownLoadAssetTask_ExpectTime", value); }
|
| | | }
|
| | |
|
| | | public override void Begin()
|
| | | {
|
| | | m_CurrentStage = LaunchStage.DownLoad;
|
| | | progressBuf = progress;
|
| | | timer = 0f;
|
| | | duration = 1.5f;
|
| | |
|
| | | AssetVersionUtility.GetAssetVersionFile();
|
| | | while (!AssetVersionUtility.checkAssetCompleted)
|
| | | duration = Mathf.Max(0.1f, expectTime);
|
| | | if (VersionUtility.Instance.NeedDownAsset())
|
| | | {
|
| | | timer += Time.deltaTime;
|
| | | progress = Mathf.Clamp(progressBuf + timer / duration * 0.3f, progressBuf, progressBuf + 0.3f);
|
| | | yield return null;
|
| | | }
|
| | |
|
| | | if (!AssetVersionUtility.priorAssetDownLoadDone)
|
| | | {
|
| | | AssetVersionUtility.BeginDownLoadTask(true);
|
| | | while (!AssetVersionUtility.priorAssetDownLoadDone)
|
| | | if (!AssetVersionUtility.priorAssetDownLoadDone)
|
| | | {
|
| | | yield return null;
|
| | | AssetVersionUtility.BeginDownLoadTask(true);
|
| | | done = false;
|
| | | progress = 0f;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | |
|
| | | yield return WaitingForSecondConst.WaitMS200;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | }
|
| | |
|
| | | public override void End()
|
| | | {
|
| | | expectTime = timer;
|
| | | DebugEx.LogFormat("{0}执行时长:{1};", this.GetType().Name, timer);
|
| | | if (!AssetVersionUtility.unPriorAssetDownLoadDone)
|
| | | {
|
| | | AssetVersionUtility.BeginDownLoadTask(false);
|
| | | }
|
| | | }
|
| | |
|
| | | if (!AssetSource.allFromEditor)
|
| | | public override void Update()
|
| | | {
|
| | | StartCoroutine(AssetBundleUtility.Instance.Initialize());
|
| | | }
|
| | |
|
| | | m_CurrentStage = LaunchStage.ConfigLoad;
|
| | | LaunchPostProcess.Instance.Begin();
|
| | |
|
| | | progressBuf = progress;
|
| | | while (!LaunchPostProcess.Instance.completed
|
| | | && LaunchPostProcess.Instance.progress < (Application.platform == RuntimePlatform.WindowsEditor ? 1f : 0.8f))
|
| | | {
|
| | | progress = Mathf.Clamp(progressBuf + LaunchPostProcess.Instance.progress * (1 - progressBuf), progressBuf, 1f);
|
| | | yield return null;
|
| | | }
|
| | |
|
| | | OperationLogCollect.Instance.RecordLauchEvent(3);
|
| | | OperationLogCollect.Instance.RecordEvent(3);
|
| | |
|
| | | LuaUtility.Instance.Init();
|
| | | CSharpCallLua.Init();
|
| | | ShaderUtility.WarmUpAll();
|
| | | SpeechTranslate.Instance.RequestGetToken();
|
| | |
|
| | | if (!AssetSource.allFromEditor)
|
| | | {
|
| | | progressBuf = progress;
|
| | | timer = 0f;
|
| | | duration = 3f;
|
| | | while (!AssetBundleUtility.Instance.initialized)
|
| | | if (done)
|
| | | {
|
| | | timer += Time.deltaTime;
|
| | | progress = Mathf.Clamp(progressBuf + timer / duration * 0.2f, progressBuf, 1f);
|
| | | yield return null;
|
| | | return;
|
| | | }
|
| | |
|
| | | AssetBundleUtility.Instance.Sync_LoadAll("ui/prioritywindow");
|
| | | SnxxzGame.Instance.StartCoroutine(AssetBundleUtility.Instance.InitalizeUIResources());
|
| | | }
|
| | |
|
| | | UI3DModelExhibition.CreateStage();
|
| | |
|
| | | var launchWin = WindowCenter.Instance.Get<LaunchWin>();
|
| | | if (launchWin != null)
|
| | | {
|
| | | launchWin.FadeOut();
|
| | | }
|
| | |
|
| | | WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
|
| | | var launchBackGroundWin = WindowCenter.Instance.Get<LaunchBackGroundWin>();
|
| | | launchBackGroundWin.transform.SetAsFirstSibling();
|
| | |
|
| | | progressBuf = progress;
|
| | | timer = 0f;
|
| | | duration = 1f;
|
| | | while (timer < duration)
|
| | | {
|
| | | timer += Time.deltaTime;
|
| | | progress = Mathf.Clamp(progressBuf + timer / duration, progressBuf, 1f);
|
| | | yield return null;
|
| | | if (!AssetVersionUtility.priorAssetDownLoadDone)
|
| | | {
|
| | | done = false;
|
| | | progress = 0f;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | |
|
| | | ExceptionReport();
|
| | | }
|
| | |
|
| | | StageManager.Instance.LoadLoginStage();
|
| | | Debug.LogFormat("启动耗时:{0}", Time.time - startTime);
|
| | | }
|
| | |
|
| | | public enum LaunchStage
|
| | | public class AssetBundleInitTask : LaunchTask
|
| | | {
|
| | | None,
|
| | | AssetCopy,
|
| | | ClientVersion,
|
| | | DownLoad,
|
| | | ConfigLoad,
|
| | | Complete,
|
| | | public override float expectTime {
|
| | | get { return LocalSave.GetFloat("AssetBundleInitTask_ExpectTime", 0.5f); }
|
| | | protected set { LocalSave.SetFloat("AssetBundleInitTask_ExpectTime", value); }
|
| | | }
|
| | |
|
| | | public override void Begin()
|
| | | {
|
| | | m_CurrentStage = LaunchStage.AssetBundleInit;
|
| | |
|
| | | duration = Mathf.Max(0.1f, expectTime);
|
| | | if (!AssetSource.allFromEditor)
|
| | | {
|
| | | AssetBundleUtility.Instance.Sync_LoadAll("ui/prioritywindow");
|
| | | SnxxzGame.Instance.StartCoroutine(AssetBundleUtility.Instance.Initialize());
|
| | | SnxxzGame.Instance.StartCoroutine(AssetBundleUtility.Instance.InitalizeUIResources());
|
| | | done = false;
|
| | | progress = 0f;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | }
|
| | |
|
| | | public override void End()
|
| | | {
|
| | | expectTime = timer;
|
| | | DebugEx.LogFormat("{0}执行时长:{1};", this.GetType().Name, timer);
|
| | | }
|
| | |
|
| | | public override void Update()
|
| | | {
|
| | | if (done)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (AssetBundleUtility.Instance.initialized && AssetBundleUtility.Instance.initializedUIAssetBundle)
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = false;
|
| | | progress = timer / duration;
|
| | | }
|
| | |
|
| | | ExceptionReport();
|
| | | }
|
| | | }
|
| | |
|
| | | public class ConfigInitTask : LaunchTask
|
| | | {
|
| | | public override float expectTime {
|
| | | get { return LocalSave.GetFloat("ConfigInitTask_ExpectTime", 5f); }
|
| | | protected set { LocalSave.SetFloat("ConfigInitTask_ExpectTime", value); }
|
| | | }
|
| | |
|
| | | float threshold = 1f;
|
| | |
|
| | | public override void Begin()
|
| | | {
|
| | | m_CurrentStage = LaunchStage.ConfigInit;
|
| | | duration = Mathf.Max(0.1f, expectTime);
|
| | | threshold = Application.platform == RuntimePlatform.WindowsEditor ? 1f : 0.9f;
|
| | |
|
| | | LaunchPostProcess.Instance.Begin();
|
| | | }
|
| | |
|
| | | public override void End()
|
| | | {
|
| | | expectTime = timer;
|
| | | DebugEx.LogFormat("{0}执行时长:{1};", this.GetType().Name, timer);
|
| | | OperationLogCollect.Instance.RecordLauchEvent(3);
|
| | | OperationLogCollect.Instance.RecordEvent(3);
|
| | | }
|
| | |
|
| | | public override void Update()
|
| | | {
|
| | | if (done)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | timer += Time.deltaTime;
|
| | | if (!LaunchPostProcess.Instance.completed && LaunchPostProcess.Instance.progress < threshold)
|
| | | {
|
| | | done = false;
|
| | | progress = timer / duration;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = true;
|
| | | }
|
| | |
|
| | | ExceptionReport();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public class LaunchFadeOutTask : LaunchTask
|
| | | {
|
| | | public override float expectTime {
|
| | | get { return LocalSave.GetFloat("LaunchFadeOutTask_ExpectTime", 1f); }
|
| | | protected set { LocalSave.SetFloat("LaunchFadeOutTask_ExpectTime", value); }
|
| | | }
|
| | |
|
| | | bool launchBackGroundLoadedOk = false;
|
| | | bool openBackGround = false;
|
| | |
|
| | | public override void Begin()
|
| | | {
|
| | | m_CurrentStage = LaunchStage.Complete;
|
| | | duration = Mathf.Max(0.1f, expectTime);
|
| | |
|
| | | LuaUtility.Instance.Init();
|
| | | CSharpCallLua.Init();
|
| | | ShaderUtility.WarmUpAll();
|
| | | SpeechTranslate.Instance.RequestGetToken();
|
| | | UI3DModelExhibition.CreateStage();
|
| | |
|
| | | var launchWin = WindowCenter.Instance.Get<LaunchWin>();
|
| | | if (launchWin != null)
|
| | | {
|
| | | launchWin.FadeOut();
|
| | | }
|
| | |
|
| | | UILoader.LoadWindowAsync("LaunchBackGroundWin",
|
| | | (bool ok, UnityEngine.Object @object) =>
|
| | | {
|
| | | if (ok)
|
| | | {
|
| | | launchBackGroundLoadedOk = true;
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | public override void End()
|
| | | {
|
| | | expectTime = timer;
|
| | | DebugEx.LogFormat("{0}执行时长:{1};", this.GetType().Name, timer);
|
| | | if (!openBackGround)
|
| | | {
|
| | | WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
|
| | | }
|
| | |
|
| | | var launchBackGroundWin = WindowCenter.Instance.Get<LaunchBackGroundWin>();
|
| | | launchBackGroundWin.transform.SetAsFirstSibling();
|
| | | }
|
| | |
|
| | | public override void Update()
|
| | | {
|
| | | if (done)
|
| | | {
|
| | | return;
|
| | | }
|
| | | timer += Time.deltaTime;
|
| | |
|
| | | if (!openBackGround)
|
| | | {
|
| | | if (launchBackGroundLoadedOk)
|
| | | {
|
| | | WindowCenter.Instance.Open<LaunchBackGroundWin>();
|
| | | openBackGround = true;
|
| | | }
|
| | | }
|
| | |
|
| | | if (timer >= expectTime)
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = false;
|
| | | progress = Mathf.Clamp01(timer / expectTime);
|
| | | }
|
| | |
|
| | | ExceptionReport();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public class WaitTask : LaunchTask
|
| | | {
|
| | | public WaitTask(float seconds)
|
| | | {
|
| | | expectTime = Mathf.Max(0.1f, seconds);
|
| | | }
|
| | |
|
| | | public override void Begin()
|
| | | {
|
| | | }
|
| | |
|
| | | public override void End()
|
| | | {
|
| | | }
|
| | |
|
| | | public override void Update()
|
| | | {
|
| | | timer += Time.deltaTime;
|
| | |
|
| | | if (timer >= expectTime)
|
| | | {
|
| | | done = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | done = false;
|
| | | progress = Mathf.Clamp01(timer / expectTime);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public struct ProgressInfo
|
| | | {
|
| | | public LaunchStage stage;
|
| | | public float totalProgress;
|
| | | public float partProgress;
|
| | |
|
| | | public ProgressInfo(LaunchStage stage, float totalProgress, float partProgress)
|
| | | {
|
| | | this.stage = stage;
|
| | | this.totalProgress = totalProgress;
|
| | | this.partProgress = partProgress;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|