mirror of https://github.com/tuyoogame/YooAsset
Update YooAssets.cs
parent
86142ed4db
commit
d5a4b3365f
|
@ -404,10 +404,7 @@ namespace YooAsset
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
BundleInfo bundleInfo = _bundleServices.GetBundleInfo(assetInfo);
|
||||||
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||||
|
@ -469,38 +466,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 场景加载
|
#region 原生文件
|
||||||
/// <summary>
|
|
||||||
/// 异步加载场景
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="location">场景的定位地址</param>
|
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
|
||||||
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
|
|
||||||
/// <param name="priority">优先级</param>
|
|
||||||
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
|
||||||
{
|
|
||||||
DebugCheckInitialize();
|
|
||||||
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
|
||||||
var handle = AssetSystem.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载场景
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="assetInfo">场景的资源信息</param>
|
|
||||||
/// <param name="sceneMode">场景加载模式</param>
|
|
||||||
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
|
|
||||||
/// <param name="priority">优先级</param>
|
|
||||||
public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
|
||||||
{
|
|
||||||
DebugCheckInitialize();
|
|
||||||
var handle = AssetSystem.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 资源加载
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步获取原生文件
|
/// 异步获取原生文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -521,6 +487,8 @@ namespace YooAsset
|
||||||
public static RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
public static RawFileOperation GetRawFileAsync(AssetInfo assetInfo, string copyPath = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
YooLogger.Warning(assetInfo.Error);
|
||||||
return GetRawFileInternal(assetInfo, copyPath);
|
return GetRawFileInternal(assetInfo, copyPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +497,6 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (assetInfo.IsInvalid)
|
if (assetInfo.IsInvalid)
|
||||||
{
|
{
|
||||||
YooLogger.Warning(assetInfo.Error);
|
|
||||||
RawFileOperation operation = new CompletedRawFileOperation(assetInfo.Error, copyPath);
|
RawFileOperation operation = new CompletedRawFileOperation(assetInfo.Error, copyPath);
|
||||||
OperationSystem.StartOperaiton(operation);
|
OperationSystem.StartOperaiton(operation);
|
||||||
return operation;
|
return operation;
|
||||||
|
@ -570,6 +537,39 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 场景加载
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载场景
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">场景的定位地址</param>
|
||||||
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
|
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
|
||||||
|
/// <param name="priority">优先级</param>
|
||||||
|
public static SceneOperationHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||||
|
var handle = AssetSystem.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步加载场景
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetInfo">场景的资源信息</param>
|
||||||
|
/// <param name="sceneMode">场景加载模式</param>
|
||||||
|
/// <param name="activateOnLoad">加载完毕时是否主动激活</param>
|
||||||
|
/// <param name="priority">优先级</param>
|
||||||
|
public static SceneOperationHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool activateOnLoad = true, int priority = 100)
|
||||||
|
{
|
||||||
|
DebugCheckInitialize();
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
YooLogger.Warning(assetInfo.Error);
|
||||||
|
var handle = AssetSystem.LoadSceneAsync(assetInfo, sceneMode, activateOnLoad, priority);
|
||||||
|
return handle;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 资源加载
|
#region 资源加载
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步加载资源对象
|
/// 同步加载资源对象
|
||||||
|
@ -578,6 +578,8 @@ namespace YooAsset
|
||||||
public static AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
|
public static AssetOperationHandle LoadAssetSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
YooLogger.Warning(assetInfo.Error);
|
||||||
return LoadAssetInternal(assetInfo, true);
|
return LoadAssetInternal(assetInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -613,6 +615,8 @@ namespace YooAsset
|
||||||
public static AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
|
public static AssetOperationHandle LoadAssetAsync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
YooLogger.Warning(assetInfo.Error);
|
||||||
return LoadAssetInternal(assetInfo, false);
|
return LoadAssetInternal(assetInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,6 +662,8 @@ namespace YooAsset
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
public static SubAssetsOperationHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
YooLogger.Warning(assetInfo.Error);
|
||||||
return LoadSubAssetsInternal(assetInfo, true);
|
return LoadSubAssetsInternal(assetInfo, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -693,6 +699,8 @@ namespace YooAsset
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
public static SubAssetsOperationHandle LoadSubAssetsAsync(AssetInfo assetInfo)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize();
|
DebugCheckInitialize();
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
YooLogger.Warning(assetInfo.Error);
|
||||||
return LoadSubAssetsInternal(assetInfo, false);
|
return LoadSubAssetsInternal(assetInfo, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1056,6 +1064,10 @@ namespace YooAsset
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 私有方法
|
#region 私有方法
|
||||||
|
/// <summary>
|
||||||
|
/// 资源定位地址转换为资源信息类,失败时内部会发出错误日志。
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>如果转换失败会返回一个无效的资源信息类</returns>
|
||||||
private static AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
private static AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
||||||
{
|
{
|
||||||
DebugCheckLocation(location);
|
DebugCheckLocation(location);
|
||||||
|
|
Loading…
Reference in New Issue