mirror of https://github.com/tuyoogame/YooAsset
YooAsset 新增IRemoteHostServices接口
HostPlayModeParameters 使用 IRemoteHostServices 获取资源服地址pull/14/head
parent
746fa44ab8
commit
ad8eb2691f
|
@ -25,12 +25,12 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(bool locationToLower, bool clearCacheWhenDirty, string defaultHostServer, string fallbackHostServer)
|
||||
public InitializationOperation InitializeAsync(bool locationToLower, bool clearCacheWhenDirty, IRemoteHostServices hostServerServices)
|
||||
{
|
||||
_locationToLower = locationToLower;
|
||||
_clearCacheWhenDirty = clearCacheWhenDirty;
|
||||
_defaultHostServer = defaultHostServer;
|
||||
_fallbackHostServer = fallbackHostServer;
|
||||
_defaultHostServer = hostServerServices.GetDefaultHost();
|
||||
_fallbackHostServer = hostServerServices.GetFallbackHost();
|
||||
|
||||
var operation = new HostPlayModeInitializationOperation(this);
|
||||
OperationSystem.StartOperaiton(operation);
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public interface IRemoteHostServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认的资源服务器下载地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string GetDefaultHost();
|
||||
|
||||
/// <summary>
|
||||
/// 备用的资源服务器下载地址
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string GetFallbackHost();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 863c6fcb409e9c4448fab48de69316b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -86,20 +86,13 @@ namespace YooAsset
|
|||
public class HostPlayModeParameters : InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新获取URL服务接口
|
||||
/// </summary>
|
||||
public IRemoteHostServices HostAddressServices;
|
||||
/// <summary>
|
||||
/// 当缓存池被污染的时候清理缓存池
|
||||
/// </summary>
|
||||
public bool ClearCacheWhenDirty;
|
||||
|
||||
/// <summary>
|
||||
/// 默认的资源服务器下载地址
|
||||
/// </summary>
|
||||
public string DefaultHostServer;
|
||||
|
||||
/// <summary>
|
||||
/// 备用的资源服务器下载地址
|
||||
/// </summary>
|
||||
public string FallbackHostServer;
|
||||
|
||||
/// <summary>
|
||||
/// 启用断点续传功能的文件大小
|
||||
/// </summary>
|
||||
|
@ -215,9 +208,7 @@ namespace YooAsset
|
|||
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
||||
initializeOperation = _hostPlayModeImpl.InitializeAsync(
|
||||
hostPlayModeParameters.LocationToLower,
|
||||
hostPlayModeParameters.ClearCacheWhenDirty,
|
||||
hostPlayModeParameters.DefaultHostServer,
|
||||
hostPlayModeParameters.FallbackHostServer);
|
||||
hostPlayModeParameters.ClearCacheWhenDirty, hostPlayModeParameters.HostAddressServices);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -234,6 +225,12 @@ namespace YooAsset
|
|||
_initializeError = op.Error;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static bool IsInitialized => _isInitialize;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 向网络端请求静态资源版本
|
||||
/// </summary>
|
||||
|
@ -557,7 +554,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetOperationHandle LoadAssetAsync<TObject>(string location)
|
||||
public static AssetOperationHandle LoadAssetAsync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||
|
|
Loading…
Reference in New Issue