You've already forked taptap2024_GJ_chidouren
91 lines
3.1 KiB
C#
91 lines
3.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.StateSystem;
|
|
using AssetLoader;
|
|
using Framework.FSMLite;
|
|
using UniFramework.Event;
|
|
using UnityEngine;
|
|
using YooAsset;
|
|
|
|
namespace StateSystem.State
|
|
{
|
|
public class StateCheckAsset : StateMachine<GameGlobalState>
|
|
{
|
|
private Uri remotePath;
|
|
private bool sMandatory;
|
|
private EPlayMode ePlayMode;
|
|
|
|
|
|
protected override void OnEnter (params object[] args)
|
|
{
|
|
Debug.Log ("开始资源检查!");
|
|
remotePath = new Uri ((string) args[0]);
|
|
Debug.Log ( "remotePath: " + remotePath);
|
|
sMandatory = GameGlobalConfig.Instance.IsMandatory;
|
|
ePlayMode = GameGlobalConfig.Instance.IsCheckNetAsset ? EPlayMode.HostPlayMode : EPlayMode.OfflinePlayMode;
|
|
|
|
#if UNITY_EDITOR
|
|
// if (ePlayMode != EPlayMode.HostPlayMode)
|
|
{
|
|
if (GameGlobalConfig.Instance.IsNativeAssets)
|
|
{
|
|
if (GameGlobalConfig.Instance.IsCheckNetAsset)
|
|
{
|
|
ePlayMode = EPlayMode.HostPlayMode;
|
|
}
|
|
else
|
|
{
|
|
ePlayMode = EPlayMode.OfflinePlayMode;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ePlayMode = EPlayMode.EditorSimulateMode;
|
|
}
|
|
}
|
|
#endif
|
|
GameManager.Instance.StartCoroutine (InitAsset ());
|
|
}
|
|
|
|
private IEnumerator InitAsset ()
|
|
{
|
|
// 初始化事件系统
|
|
UniEvent.Initalize ();
|
|
|
|
// 初始化资源系统
|
|
YooAssets.Initialize ();
|
|
|
|
yield return new WaitForSeconds (0.1f);
|
|
|
|
// 创建资源包裹类配置表
|
|
var content
|
|
= new AssetBundleLoader.Content (null , remotePath , "DefaultPackage" , GameManager.Instance);
|
|
content.BuildPipeline = EDefaultBuildPipeline.BuiltinBuildPipeline;
|
|
content.IsStrictModeUpdate = sMandatory;
|
|
content.PlayMode = ePlayMode;
|
|
content.ClientVersion = GameGlobalConfig.Instance.ClientBuildID.ToString ();
|
|
// 创建资源加载器
|
|
var loader = new AssetBundleLoader (content);
|
|
// 创建资源加载适配器 ,与外部UI交互
|
|
AssetLoadDrawAdapter adapter = new AssetLoadDrawAdapter (BeginStaticPanel.ShowMessage , BeginStaticPanel.ShowMessageBox);
|
|
|
|
adapter.OnCompleteCallBack = OnCheckComplete;
|
|
//开始资源加载
|
|
loader.StartLoad (adapter);
|
|
}
|
|
|
|
private void OnCheckComplete ()
|
|
{
|
|
// 设置默认的资源包
|
|
var gamePackage = YooAssets.GetPackage ("DefaultPackage");
|
|
YooAssets.SetDefaultPackage (gamePackage);
|
|
|
|
Debug.Log ("资源检查结束");
|
|
this.stateMachineRunner.OpenState (GameGlobalState.GameInit, true);
|
|
}
|
|
|
|
protected override void OnExit ()
|
|
{
|
|
}
|
|
}
|
|
} |