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>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(bool locationToLower, bool clearCacheWhenDirty, string defaultHostServer, string fallbackHostServer)
|
public InitializationOperation InitializeAsync(bool locationToLower, bool clearCacheWhenDirty, IRemoteHostServices hostServerServices)
|
||||||
{
|
{
|
||||||
_locationToLower = locationToLower;
|
_locationToLower = locationToLower;
|
||||||
_clearCacheWhenDirty = clearCacheWhenDirty;
|
_clearCacheWhenDirty = clearCacheWhenDirty;
|
||||||
_defaultHostServer = defaultHostServer;
|
_defaultHostServer = hostServerServices.GetDefaultHost();
|
||||||
_fallbackHostServer = fallbackHostServer;
|
_fallbackHostServer = hostServerServices.GetFallbackHost();
|
||||||
|
|
||||||
var operation = new HostPlayModeInitializationOperation(this);
|
var operation = new HostPlayModeInitializationOperation(this);
|
||||||
OperationSystem.StartOperaiton(operation);
|
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
|
public class HostPlayModeParameters : InitializeParameters
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 资源更新获取URL服务接口
|
||||||
|
/// </summary>
|
||||||
|
public IRemoteHostServices HostAddressServices;
|
||||||
|
/// <summary>
|
||||||
/// 当缓存池被污染的时候清理缓存池
|
/// 当缓存池被污染的时候清理缓存池
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ClearCacheWhenDirty;
|
public bool ClearCacheWhenDirty;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 默认的资源服务器下载地址
|
|
||||||
/// </summary>
|
|
||||||
public string DefaultHostServer;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 备用的资源服务器下载地址
|
|
||||||
/// </summary>
|
|
||||||
public string FallbackHostServer;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用断点续传功能的文件大小
|
/// 启用断点续传功能的文件大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -215,9 +208,7 @@ namespace YooAsset
|
||||||
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
var hostPlayModeParameters = parameters as HostPlayModeParameters;
|
||||||
initializeOperation = _hostPlayModeImpl.InitializeAsync(
|
initializeOperation = _hostPlayModeImpl.InitializeAsync(
|
||||||
hostPlayModeParameters.LocationToLower,
|
hostPlayModeParameters.LocationToLower,
|
||||||
hostPlayModeParameters.ClearCacheWhenDirty,
|
hostPlayModeParameters.ClearCacheWhenDirty, hostPlayModeParameters.HostAddressServices);
|
||||||
hostPlayModeParameters.DefaultHostServer,
|
|
||||||
hostPlayModeParameters.FallbackHostServer);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -234,6 +225,12 @@ namespace YooAsset
|
||||||
_initializeError = op.Error;
|
_initializeError = op.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsInitialized => _isInitialize;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求静态资源版本
|
/// 向网络端请求静态资源版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -557,7 +554,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TObject">资源类型</typeparam>
|
/// <typeparam name="TObject">资源类型</typeparam>
|
||||||
/// <param name="location">资源的定位地址</param>
|
/// <param name="location">资源的定位地址</param>
|
||||||
public static AssetOperationHandle LoadAssetAsync<TObject>(string location)
|
public static AssetOperationHandle LoadAssetAsync<TObject>(string location) where TObject : UnityEngine.Object
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, typeof(TObject));
|
||||||
|
|
Loading…
Reference in New Issue