Update runtime logic

pull/40/head
hevinci 2022-09-28 11:55:12 +08:00
parent c8d3f6efed
commit a4c8fb6e1b
10 changed files with 146 additions and 214 deletions

View File

@ -11,7 +11,7 @@ namespace YooAsset
/// </summary> /// </summary>
internal abstract class PatchCacheVerifier internal abstract class PatchCacheVerifier
{ {
public abstract bool InitVerifier(PatchManifest appPatchManifest, PatchManifest localPatchManifest, bool weaklyUpdate); public abstract bool InitVerifier(HostPlayModeImpl impl, bool weaklyUpdate);
public abstract bool UpdateVerifier(); public abstract bool UpdateVerifier();
public abstract float GetVerifierProgress(); public abstract float GetVerifierProgress();
@ -42,22 +42,18 @@ namespace YooAsset
private int _verifyMaxNum; private int _verifyMaxNum;
private int _verifyTotalCount; private int _verifyTotalCount;
public override bool InitVerifier(PatchManifest appPatchManifest, PatchManifest localPatchManifest, bool weaklyUpdate) public override bool InitVerifier(HostPlayModeImpl impl, bool weaklyUpdate)
{ {
// 遍历所有文件然后验证并缓存合法文件 // 遍历所有文件然后验证并缓存合法文件
foreach (var patchBundle in localPatchManifest.BundleList) foreach (var patchBundle in impl.LocalPatchManifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.IsCached(patchBundle)) if (CacheSystem.IsCached(patchBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源
// 注意如果是APP资源并且哈希值相同则不需要下载 if (impl.IsBuildinPatchBundle(patchBundle))
if (appPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Equals(patchBundle))
continue; continue;
}
// 注意:在弱联网模式下,我们需要验证指定资源版本的所有资源完整性 // 注意:在弱联网模式下,我们需要验证指定资源版本的所有资源完整性
if (weaklyUpdate) if (weaklyUpdate)
@ -167,22 +163,18 @@ namespace YooAsset
private int _verifyMaxNum; private int _verifyMaxNum;
private int _verifyTotalCount; private int _verifyTotalCount;
public override bool InitVerifier(PatchManifest appPatchManifest, PatchManifest localPatchManifest, bool weaklyUpdate) public override bool InitVerifier(HostPlayModeImpl impl, bool weaklyUpdate)
{ {
// 遍历所有文件然后验证并缓存合法文件 // 遍历所有文件然后验证并缓存合法文件
foreach (var patchBundle in localPatchManifest.BundleList) foreach (var patchBundle in impl.LocalPatchManifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.IsCached(patchBundle)) if (CacheSystem.IsCached(patchBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源
// 注意如果是APP资源并且哈希值相同则不需要下载 if (impl.IsBuildinPatchBundle(patchBundle))
if (appPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Equals(patchBundle))
continue; continue;
}
// 注意:在弱联网模式下,我们需要验证指定资源版本的所有资源完整性 // 注意:在弱联网模式下,我们需要验证指定资源版本的所有资源完整性
if (weaklyUpdate) if (weaklyUpdate)

View File

@ -134,75 +134,15 @@ namespace YooAsset
/// </summary> /// </summary>
internal sealed class HostPlayModeInitializationOperation : InitializationOperation internal sealed class HostPlayModeInitializationOperation : InitializationOperation
{ {
private enum ESteps internal HostPlayModeInitializationOperation()
{ {
None,
LoadManifest,
CopyManifest,
Done,
}
private readonly HostPlayModeImpl _impl;
private readonly string _buildinPackageName;
private AppManifestLoader _appManifestLoader;
private AppManifestCopyer _appManifestCopyer;
private ESteps _steps = ESteps.None;
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl, string buildinPackageName)
{
_impl = impl;
_buildinPackageName = buildinPackageName;
_appManifestLoader = new AppManifestLoader(buildinPackageName);
} }
internal override void Start() internal override void Start()
{ {
_steps = ESteps.LoadManifest; Status = EOperationStatus.Succeed;
} }
internal override void Update() internal override void Update()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.LoadManifest)
{
_appManifestLoader.Update();
Progress = _appManifestLoader.Progress();
if (_appManifestLoader.IsDone() == false)
return;
if (_appManifestLoader.Result == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _appManifestLoader.Error;
}
else
{
_impl.SetAppPatchManifest(_appManifestLoader.Result);
_impl.SetLocalPatchManifest(_appManifestLoader.Result);
_appManifestCopyer = new AppManifestCopyer(_buildinPackageName, _appManifestLoader.BuildinPackageCRC);
_steps = ESteps.CopyManifest;
}
}
if (_steps == ESteps.CopyManifest)
{
_appManifestCopyer.Update();
if (_appManifestCopyer.IsDone() == false)
return;
if (_appManifestCopyer.Result == false)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _appManifestCopyer.Error;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
}
} }
} }

View File

@ -154,7 +154,7 @@ namespace YooAsset
if (_steps == ESteps.InitVerifyingCache) if (_steps == ESteps.InitVerifyingCache)
{ {
_patchCacheVerifier.InitVerifier(_impl.AppPatchManifest, _impl.LocalPatchManifest, false); _patchCacheVerifier.InitVerifier(_impl, false);
_verifyTime = UnityEngine.Time.realtimeSinceStartup; _verifyTime = UnityEngine.Time.realtimeSinceStartup;
_steps = ESteps.UpdateVerifyingCache; _steps = ESteps.UpdateVerifyingCache;
} }
@ -286,7 +286,7 @@ namespace YooAsset
if (_steps == ESteps.InitVerifyingCache) if (_steps == ESteps.InitVerifyingCache)
{ {
if (_patchCacheVerifier.InitVerifier(_impl.AppPatchManifest, _impl.LocalPatchManifest, true)) if (_patchCacheVerifier.InitVerifier(_impl, true))
{ {
_verifyTime = UnityEngine.Time.realtimeSinceStartup; _verifyTime = UnityEngine.Time.realtimeSinceStartup;
_steps = ESteps.UpdateVerifyingCache; _steps = ESteps.UpdateVerifyingCache;

View File

@ -205,12 +205,8 @@ namespace YooAsset
continue; continue;
// 忽略APP资源 // 忽略APP资源
// 注意如果是APP资源并且哈希值相同则不需要下载 if (_impl.IsBuildinPatchBundle(patchBundle))
if (_impl.AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Equals(patchBundle))
continue; continue;
}
downloadList.Add(patchBundle); downloadList.Add(patchBundle);
} }

View File

@ -38,21 +38,16 @@ namespace YooAsset
public int Flags; public int Flags;
/// <summary>
/// 是否为加密文件
/// </summary>
public bool IsEncrypted { private set; get; }
/// <summary>
/// 是否为内置文件
/// </summary>
public bool IsBuildin { private set; get; }
/// <summary> /// <summary>
/// 是否为原生文件 /// 是否为原生文件
/// </summary> /// </summary>
public bool IsRawFile { private set; get; } public bool IsRawFile { private set; get; }
/// <summary>
/// 是否为加密文件
/// </summary>
public bool IsEncrypted { private set; get; }
/// <summary> /// <summary>
/// 文件名称 /// 文件名称
/// </summary> /// </summary>
@ -104,16 +99,14 @@ namespace YooAsset
/// <summary> /// <summary>
/// 设置Flags /// 设置Flags
/// </summary> /// </summary>
public void SetFlagsValue(bool isEncrypted, bool isBuildin, bool isRawFile) public void SetFlagsValue(bool isRawFile, bool isEncrypted)
{ {
IsEncrypted = isEncrypted;
IsBuildin = isBuildin;
IsRawFile = isRawFile; IsRawFile = isRawFile;
IsEncrypted = isEncrypted;
BitMask32 mask = new BitMask32(0); BitMask32 mask = new BitMask32(0);
if (isEncrypted) mask.Open(0); if (isRawFile) mask.Open(0);
if (isBuildin) mask.Open(1); if (isEncrypted) mask.Open(1);
if (isRawFile) mask.Open(2);
Flags = mask; Flags = mask;
} }
@ -123,9 +116,8 @@ namespace YooAsset
public void ParseFlagsValue() public void ParseFlagsValue()
{ {
BitMask32 value = Flags; BitMask32 value = Flags;
IsEncrypted = value.Test(0); IsRawFile = value.Test(0);
IsBuildin = value.Test(1); IsEncrypted = value.Test(1);
IsRawFile = value.Test(2);
} }
/// <summary> /// <summary>
@ -179,11 +171,11 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 是否为纯内置资源不带任何Tag的资源 /// 是否包含任意Tags
/// </summary> /// </summary>
public bool IsPureBuildin() public bool HasAnyTags()
{ {
if (Tags == null || Tags.Length == 0) if (Tags != null && Tags.Length > 0)
return true; return true;
else else
return false; return false;

View File

@ -32,11 +32,6 @@ namespace YooAsset
/// </summary> /// </summary>
public string PackageName; public string PackageName;
/// <summary>
/// 内置资源的标签列表(首包资源)
/// </summary>
public string BuildinTags;
/// <summary> /// <summary>
/// 资源列表(主动收集的资源列表) /// 资源列表(主动收集的资源列表)
/// </summary> /// </summary>

View File

@ -8,24 +8,25 @@ namespace YooAsset
internal class HostPlayModeImpl : IBundleServices internal class HostPlayModeImpl : IBundleServices
{ {
// 补丁清单 // 补丁清单
internal PatchManifest AppPatchManifest { private set; get; }
internal PatchManifest LocalPatchManifest { private set; get; } internal PatchManifest LocalPatchManifest { private set; get; }
// 参数相关 // 参数相关
private bool _locationToLower; private bool _locationToLower;
private string _defaultHostServer; private string _defaultHostServer;
private string _fallbackHostServer; private string _fallbackHostServer;
private IQueryServices _queryServices;
/// <summary> /// <summary>
/// 异步初始化 /// 异步初始化
/// </summary> /// </summary>
public InitializationOperation InitializeAsync(bool locationToLower, string buildinPackageName, string defaultHostServer, string fallbackHostServer) public InitializationOperation InitializeAsync(bool locationToLower, string defaultHostServer, string fallbackHostServer, IQueryServices queryServices)
{ {
_locationToLower = locationToLower; _locationToLower = locationToLower;
_defaultHostServer = defaultHostServer; _defaultHostServer = defaultHostServer;
_fallbackHostServer = fallbackHostServer; _fallbackHostServer = fallbackHostServer;
_queryServices = queryServices;
var operation = new HostPlayModeInitializationOperation(this, buildinPackageName); var operation = new HostPlayModeInitializationOperation();
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
@ -118,12 +119,8 @@ namespace YooAsset
continue; continue;
// 忽略APP资源 // 忽略APP资源
// 注意如果是APP资源并且哈希值相同则不需要下载 if (IsBuildinPatchBundle(patchBundle))
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Equals(patchBundle))
continue; continue;
}
downloadList.Add(patchBundle); downloadList.Add(patchBundle);
} }
@ -150,17 +147,11 @@ namespace YooAsset
continue; continue;
// 忽略APP资源 // 忽略APP资源
// 注意如果是APP资源并且哈希值相同则不需要下载 if (IsBuildinPatchBundle(patchBundle))
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Equals(patchBundle))
continue; continue;
}
// 如果是纯内置资源,则统一下载 // 如果未带任何标记,则统一下载
// 注意:可能是新增的或者变化的内置资源 if (patchBundle.HasAnyTags() == false)
// 注意:可能是由热更资源转换的内置资源
if (patchBundle.IsPureBuildin())
{ {
downloadList.Add(patchBundle); downloadList.Add(patchBundle);
} }
@ -220,12 +211,8 @@ namespace YooAsset
continue; continue;
// 忽略APP资源 // 忽略APP资源
// 注意如果是APP资源并且哈希值相同则不需要下载 if (IsBuildinPatchBundle(patchBundle))
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle))
{
if (appPatchBundle.IsBuildin && appPatchBundle.Equals(patchBundle))
continue; continue;
}
downloadList.Add(patchBundle); downloadList.Add(patchBundle);
} }
@ -245,22 +232,21 @@ namespace YooAsset
private List<BundleInfo> GetUnpackListByTags(string[] tags) private List<BundleInfo> GetUnpackListByTags(string[] tags)
{ {
List<PatchBundle> downloadList = new List<PatchBundle>(1000); List<PatchBundle> downloadList = new List<PatchBundle>(1000);
foreach (var patchBundle in AppPatchManifest.BundleList) foreach (var patchBundle in LocalPatchManifest.BundleList)
{ {
// 如果不是内置资源
if (patchBundle.IsBuildin == false)
continue;
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.IsCached(patchBundle)) if (CacheSystem.IsCached(patchBundle))
continue; continue;
// 查询DLC资源 // 查询DLC资源
if (IsBuildinPatchBundle(patchBundle))
{
if (patchBundle.HasTag(tags)) if (patchBundle.HasTag(tags))
{ {
downloadList.Add(patchBundle); downloadList.Add(patchBundle);
} }
} }
}
return PatchHelper.ConvertToUnpackList(downloadList); return PatchHelper.ConvertToUnpackList(downloadList);
} }
@ -277,18 +263,17 @@ namespace YooAsset
private List<BundleInfo> GetUnpackListByAll() private List<BundleInfo> GetUnpackListByAll()
{ {
List<PatchBundle> downloadList = new List<PatchBundle>(1000); List<PatchBundle> downloadList = new List<PatchBundle>(1000);
foreach (var patchBundle in AppPatchManifest.BundleList) foreach (var patchBundle in LocalPatchManifest.BundleList)
{ {
// 如果不是内置资源
if (patchBundle.IsBuildin == false)
continue;
// 忽略缓存文件 // 忽略缓存文件
if (CacheSystem.IsCached(patchBundle)) if (CacheSystem.IsCached(patchBundle))
continue; continue;
if (IsBuildinPatchBundle(patchBundle))
{
downloadList.Add(patchBundle); downloadList.Add(patchBundle);
} }
}
return PatchHelper.ConvertToUnpackList(downloadList); return PatchHelper.ConvertToUnpackList(downloadList);
} }
@ -322,16 +307,15 @@ namespace YooAsset
return bundleInfo; return bundleInfo;
} }
// 设置资源清单
internal void SetAppPatchManifest(PatchManifest patchManifest)
{
AppPatchManifest = patchManifest;
}
internal void SetLocalPatchManifest(PatchManifest patchManifest) internal void SetLocalPatchManifest(PatchManifest patchManifest)
{ {
LocalPatchManifest = patchManifest; LocalPatchManifest = patchManifest;
LocalPatchManifest.InitAssetPathMapping(_locationToLower); LocalPatchManifest.InitAssetPathMapping(_locationToLower);
} }
internal bool IsBuildinPatchBundle(PatchBundle patchBundle)
{
return _queryServices.QueryStreamingAssets(patchBundle.FileName);
}
#region IBundleServices接口 #region IBundleServices接口
private BundleInfo CreateBundleInfo(PatchBundle patchBundle) private BundleInfo CreateBundleInfo(PatchBundle patchBundle)
@ -347,14 +331,11 @@ namespace YooAsset
} }
// 查询APP资源 // 查询APP资源
if (AppPatchManifest.TryGetPatchBundle(patchBundle.BundleName, out PatchBundle appPatchBundle)) if (IsBuildinPatchBundle(patchBundle))
{ {
if (appPatchBundle.IsBuildin && appPatchBundle.Equals(patchBundle)) BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
{
BundleInfo bundleInfo = new BundleInfo(appPatchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
return bundleInfo; return bundleInfo;
} }
}
// 从服务端下载 // 从服务端下载
return ConvertToDownloadInfo(patchBundle); return ConvertToDownloadInfo(patchBundle);

View File

@ -0,0 +1,11 @@

namespace YooAsset
{
public interface IQueryServices
{
/// <summary>
/// 查询内置资源
/// </summary>
bool QueryStreamingAssets(string fileName);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 71b4ac2c7d7f15b40a457f355d535f33
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -40,11 +40,6 @@ namespace YooAsset
/// </summary> /// </summary>
public bool LocationToLower = false; public bool LocationToLower = false;
/// <summary>
/// 内置的资源包裹名称
/// </summary>
public string BuildinPackageName = string.Empty;
/// <summary> /// <summary>
/// 资源定位服务接口 /// 资源定位服务接口
/// </summary> /// </summary>
@ -83,6 +78,10 @@ namespace YooAsset
/// </summary> /// </summary>
public class OfflinePlayModeParameters : InitializeParameters public class OfflinePlayModeParameters : InitializeParameters
{ {
/// <summary>
/// 内置的资源包裹名称
/// </summary>
public string BuildinPackageName = string.Empty;
} }
/// <summary> /// <summary>
@ -100,11 +99,6 @@ namespace YooAsset
/// </summary> /// </summary>
public string FallbackHostServer; public string FallbackHostServer;
/// <summary>
/// 当缓存池被污染的时候清理缓存池
/// </summary>
public bool ClearCacheWhenDirty = false;
#if UNITY_WEBGL #if UNITY_WEBGL
/// <summary> /// <summary>
/// WEBGL模式不支持多线程下载 /// WEBGL模式不支持多线程下载
@ -121,6 +115,11 @@ namespace YooAsset
/// 下载文件校验等级 /// 下载文件校验等级
/// </summary> /// </summary>
public EVerifyLevel VerifyLevel = EVerifyLevel.High; public EVerifyLevel VerifyLevel = EVerifyLevel.High;
/// <summary>
/// 查询服务类
/// </summary>
public IQueryServices QueryServices = null;
} }
@ -151,36 +150,45 @@ namespace YooAsset
if (parameters == null) if (parameters == null)
throw new Exception($"YooAsset create parameters is null."); throw new Exception($"YooAsset create parameters is null.");
if (string.IsNullOrEmpty(parameters.BuildinPackageName))
throw new Exception($"{nameof(parameters.BuildinPackageName)} is empty.");
if (parameters.LocationServices == null)
throw new Exception($"{nameof(IBundleServices)} is null.");
#if !UNITY_EDITOR #if !UNITY_EDITOR
if (parameters is EditorSimulateModeParameters) if (parameters is EditorSimulateModeParameters)
throw new Exception($"Editor simulate mode only support unity editor."); throw new Exception($"Editor simulate mode only support unity editor.");
#endif #endif
_locationServices = parameters.LocationServices; // 鉴定运行模式
if (parameters is EditorSimulateModeParameters)
// 创建驱动器 _playMode = EPlayMode.EditorSimulateMode;
if (_isInitialize == false) else if (parameters is OfflinePlayModeParameters)
{ _playMode = EPlayMode.OfflinePlayMode;
_isInitialize = true; else if (parameters is HostPlayModeParameters)
UnityEngine.GameObject driverGo = new UnityEngine.GameObject("[YooAsset]"); _playMode = EPlayMode.HostPlayMode;
driverGo.AddComponent<YooAssetDriver>();
UnityEngine.Object.DontDestroyOnLoad(driverGo);
#if DEBUG
driverGo.AddComponent<RemoteDebuggerInRuntime>();
#endif
}
else else
throw new NotImplementedException();
if (parameters.LocationServices == null)
throw new Exception($"{nameof(IBundleServices)} is null.");
if (_playMode == EPlayMode.OfflinePlayMode)
{
var playModeParameters = parameters as OfflinePlayModeParameters;
if (string.IsNullOrEmpty(playModeParameters.BuildinPackageName))
throw new Exception($"{nameof(playModeParameters.BuildinPackageName)} is empty.");
}
if (_playMode == EPlayMode.HostPlayMode)
{
var playModeParameters = parameters as HostPlayModeParameters;
if (playModeParameters.QueryServices == null)
throw new Exception($"{nameof(IQueryServices)} is null.");
}
if (_isInitialize)
{ {
throw new Exception("YooAsset is initialized yet."); throw new Exception("YooAsset is initialized yet.");
} }
_locationServices = parameters.LocationServices;
// 检测参数范围 // 检测参数范围
if (parameters.AssetLoadingMaxNumber < 1) if (parameters.AssetLoadingMaxNumber < 1)
{ {
@ -193,17 +201,20 @@ namespace YooAsset
YooLogger.Warning($"{nameof(parameters.OperationSystemMaxTimeSlice)} minimum value is 30 milliseconds"); YooLogger.Warning($"{nameof(parameters.OperationSystemMaxTimeSlice)} minimum value is 30 milliseconds");
} }
// 鉴定运行模式 // 创建驱动器
if (parameters is EditorSimulateModeParameters) if (_isInitialize == false)
_playMode = EPlayMode.EditorSimulateMode; {
else if (parameters is OfflinePlayModeParameters) _isInitialize = true;
_playMode = EPlayMode.OfflinePlayMode; UnityEngine.GameObject driverGo = new UnityEngine.GameObject("[YooAsset]");
else if (parameters is HostPlayModeParameters) driverGo.AddComponent<YooAssetDriver>();
_playMode = EPlayMode.HostPlayMode; UnityEngine.Object.DontDestroyOnLoad(driverGo);
else
throw new NotImplementedException();
// 初始化异步操作系统 #if DEBUG
driverGo.AddComponent<RemoteDebuggerInRuntime>();
#endif
}
// 初始化异步系统
OperationSystem.Initialize(parameters.OperationSystemMaxTimeSlice); OperationSystem.Initialize(parameters.OperationSystemMaxTimeSlice);
// 初始化下载系统 // 初始化下载系统
@ -226,29 +237,32 @@ namespace YooAsset
_editorSimulateModeImpl = new EditorSimulateModeImpl(); _editorSimulateModeImpl = new EditorSimulateModeImpl();
_bundleServices = _editorSimulateModeImpl; _bundleServices = _editorSimulateModeImpl;
AssetSystem.Initialize(true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices); AssetSystem.Initialize(true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters; var simulateModeParameters = parameters as EditorSimulateModeParameters;
initializeOperation = _editorSimulateModeImpl.InitializeAsync( initializeOperation = _editorSimulateModeImpl.InitializeAsync(
editorSimulateModeParameters.LocationToLower, simulateModeParameters.LocationToLower,
editorSimulateModeParameters.SimulatePatchManifestPath); simulateModeParameters.SimulatePatchManifestPath);
} }
else if (_playMode == EPlayMode.OfflinePlayMode) else if (_playMode == EPlayMode.OfflinePlayMode)
{ {
_offlinePlayModeImpl = new OfflinePlayModeImpl(); _offlinePlayModeImpl = new OfflinePlayModeImpl();
_bundleServices = _offlinePlayModeImpl; _bundleServices = _offlinePlayModeImpl;
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices); AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
initializeOperation = _offlinePlayModeImpl.InitializeAsync(parameters.LocationToLower, parameters.BuildinPackageName); var playModeParameters = parameters as OfflinePlayModeParameters;
initializeOperation = _offlinePlayModeImpl.InitializeAsync(
playModeParameters.LocationToLower,
playModeParameters.BuildinPackageName);
} }
else if (_playMode == EPlayMode.HostPlayMode) else if (_playMode == EPlayMode.HostPlayMode)
{ {
_hostPlayModeImpl = new HostPlayModeImpl(); _hostPlayModeImpl = new HostPlayModeImpl();
_bundleServices = _hostPlayModeImpl; _bundleServices = _hostPlayModeImpl;
AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices); AssetSystem.Initialize(false, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
var hostPlayModeParameters = parameters as HostPlayModeParameters; var playModeParameters = parameters as HostPlayModeParameters;
initializeOperation = _hostPlayModeImpl.InitializeAsync( initializeOperation = _hostPlayModeImpl.InitializeAsync(
hostPlayModeParameters.LocationToLower, playModeParameters.LocationToLower,
hostPlayModeParameters.BuildinPackageName, playModeParameters.DefaultHostServer,
hostPlayModeParameters.DefaultHostServer, playModeParameters.FallbackHostServer,
hostPlayModeParameters.FallbackHostServer); playModeParameters.QueryServices);
} }
else else
{ {