mirror of https://github.com/tuyoogame/YooAsset
Update AssetSystem
parent
8373df547b
commit
39c69b1d98
|
@ -9,7 +9,7 @@ namespace YooAsset
|
||||||
internal static class AssetSystem
|
internal static class AssetSystem
|
||||||
{
|
{
|
||||||
private static readonly List<BundleFileLoader> _loaders = new List<BundleFileLoader>(1000);
|
private static readonly List<BundleFileLoader> _loaders = new List<BundleFileLoader>(1000);
|
||||||
private static readonly List<AssetProviderBase> _providers = new List<AssetProviderBase>(1000);
|
private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 在编辑器下模拟运行
|
/// 在编辑器下模拟运行
|
||||||
|
@ -132,7 +132,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static SceneOperationHandle LoadSceneAsync(string scenePath, LoadSceneMode sceneMode, bool activateOnLoad, int priority)
|
public static SceneOperationHandle LoadSceneAsync(string scenePath, LoadSceneMode sceneMode, bool activateOnLoad, int priority)
|
||||||
{
|
{
|
||||||
AssetProviderBase provider = TryGetAssetProvider(scenePath);
|
ProviderBase provider = TryGetProvider(scenePath);
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
{
|
{
|
||||||
if (SimulationOnEditor)
|
if (SimulationOnEditor)
|
||||||
|
@ -149,7 +149,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static AssetOperationHandle LoadAssetAsync(string assetPath, System.Type assetType)
|
public static AssetOperationHandle LoadAssetAsync(string assetPath, System.Type assetType)
|
||||||
{
|
{
|
||||||
AssetProviderBase provider = TryGetAssetProvider(assetPath);
|
ProviderBase provider = TryGetProvider(assetPath);
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
{
|
{
|
||||||
if (SimulationOnEditor)
|
if (SimulationOnEditor)
|
||||||
|
@ -166,7 +166,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static SubAssetsOperationHandle LoadSubAssetsAsync(string assetPath, System.Type assetType)
|
public static SubAssetsOperationHandle LoadSubAssetsAsync(string assetPath, System.Type assetType)
|
||||||
{
|
{
|
||||||
AssetProviderBase provider = TryGetAssetProvider(assetPath);
|
ProviderBase provider = TryGetProvider(assetPath);
|
||||||
if (provider == null)
|
if (provider == null)
|
||||||
{
|
{
|
||||||
if (SimulationOnEditor)
|
if (SimulationOnEditor)
|
||||||
|
@ -200,7 +200,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
internal static void RemoveBundleProviders(List<AssetProviderBase> providers)
|
internal static void RemoveBundleProviders(List<ProviderBase> providers)
|
||||||
{
|
{
|
||||||
foreach (var provider in providers)
|
foreach (var provider in providers)
|
||||||
{
|
{
|
||||||
|
@ -234,12 +234,12 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
return loader;
|
return loader;
|
||||||
}
|
}
|
||||||
private static AssetProviderBase TryGetAssetProvider(string assetPath)
|
private static ProviderBase TryGetProvider(string assetPath)
|
||||||
{
|
{
|
||||||
AssetProviderBase provider = null;
|
ProviderBase provider = null;
|
||||||
for (int i = 0; i < _providers.Count; i++)
|
for (int i = 0; i < _providers.Count; i++)
|
||||||
{
|
{
|
||||||
AssetProviderBase temp = _providers[i];
|
ProviderBase temp = _providers[i];
|
||||||
if (temp.AssetPath.Equals(assetPath))
|
if (temp.AssetPath.Equals(assetPath))
|
||||||
{
|
{
|
||||||
provider = temp;
|
provider = temp;
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsDestroyed { private set; get; } = false;
|
public bool IsDestroyed { private set; get; } = false;
|
||||||
|
|
||||||
private readonly List<AssetProviderBase> _providers = new List<AssetProviderBase>(100);
|
private readonly List<ProviderBase> _providers = new List<ProviderBase>(100);
|
||||||
private bool _isWaitForAsyncComplete = false;
|
private bool _isWaitForAsyncComplete = false;
|
||||||
private bool _isShowWaitForAsyncError = false;
|
private bool _isShowWaitForAsyncError = false;
|
||||||
private FileDownloader _fileDownloader;
|
private FileDownloader _fileDownloader;
|
||||||
|
@ -69,7 +69,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加附属的资源提供者
|
/// 添加附属的资源提供者
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void AddProvider(AssetProviderBase provider)
|
public void AddProvider(ProviderBase provider)
|
||||||
{
|
{
|
||||||
if (_providers.Contains(provider) == false)
|
if (_providers.Contains(provider) == false)
|
||||||
_providers.Add(provider);
|
_providers.Add(provider);
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
private System.Action<AssetOperationHandle> _callback;
|
private System.Action<AssetOperationHandle> _callback;
|
||||||
|
|
||||||
internal AssetOperationHandle(AssetProviderBase provider) : base(provider)
|
internal AssetOperationHandle(ProviderBase provider) : base(provider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal override void InvokeCallback()
|
internal override void InvokeCallback()
|
||||||
|
|
|
@ -4,9 +4,9 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
public abstract class OperationHandleBase : IEnumerator
|
public abstract class OperationHandleBase : IEnumerator
|
||||||
{
|
{
|
||||||
internal AssetProviderBase _provider { private set; get; }
|
internal ProviderBase _provider { private set; get; }
|
||||||
|
|
||||||
internal OperationHandleBase(AssetProviderBase provider)
|
internal OperationHandleBase(ProviderBase provider)
|
||||||
{
|
{
|
||||||
_provider = provider;
|
_provider = provider;
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,9 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (IsValid == false)
|
if (IsValid == false)
|
||||||
return EOperationStatus.None;
|
return EOperationStatus.None;
|
||||||
if (_provider.Status == AssetProviderBase.EStatus.Fail)
|
if (_provider.Status == ProviderBase.EStatus.Fail)
|
||||||
return EOperationStatus.Failed;
|
return EOperationStatus.Failed;
|
||||||
else if (_provider.Status == AssetProviderBase.EStatus.Success)
|
else if (_provider.Status == ProviderBase.EStatus.Success)
|
||||||
return EOperationStatus.Succeed;
|
return EOperationStatus.Succeed;
|
||||||
else
|
else
|
||||||
return EOperationStatus.None;
|
return EOperationStatus.None;
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace YooAsset
|
||||||
|
|
||||||
private System.Action<SceneOperationHandle> _callback;
|
private System.Action<SceneOperationHandle> _callback;
|
||||||
|
|
||||||
internal SceneOperationHandle(AssetProviderBase provider) : base(provider)
|
internal SceneOperationHandle(ProviderBase provider) : base(provider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal override void InvokeCallback()
|
internal override void InvokeCallback()
|
||||||
|
@ -189,7 +189,7 @@ namespace YooAsset
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssetProviderBase provider = _provider;
|
ProviderBase provider = _provider;
|
||||||
|
|
||||||
// 释放场景句柄
|
// 释放场景句柄
|
||||||
ReleaseInternal();
|
ReleaseInternal();
|
||||||
|
@ -222,7 +222,7 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsAdditiveScene(AssetProviderBase provider)
|
private bool IsAdditiveScene(ProviderBase provider)
|
||||||
{
|
{
|
||||||
if (provider is DatabaseSceneProvider)
|
if (provider is DatabaseSceneProvider)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
private System.Action<SubAssetsOperationHandle> _callback;
|
private System.Action<SubAssetsOperationHandle> _callback;
|
||||||
|
|
||||||
internal SubAssetsOperationHandle(AssetProviderBase provider) : base(provider)
|
internal SubAssetsOperationHandle(ProviderBase provider) : base(provider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal override void InvokeCallback()
|
internal override void InvokeCallback()
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal abstract class BundledProvider : AssetProviderBase
|
internal abstract class BundledProvider : ProviderBase
|
||||||
{
|
{
|
||||||
protected BundleFileLoader OwnerBundle { private set; get; }
|
protected BundleFileLoader OwnerBundle { private set; get; }
|
||||||
protected DependBundleGrouper DependBundles { private set; get; }
|
protected DependBundleGrouper DependBundles { private set; get; }
|
||||||
|
|
|
@ -4,7 +4,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal sealed class DatabaseAssetProvider : AssetProviderBase
|
internal sealed class DatabaseAssetProvider : ProviderBase
|
||||||
{
|
{
|
||||||
public override float Progress
|
public override float Progress
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@ using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal sealed class DatabaseSceneProvider : AssetProviderBase
|
internal sealed class DatabaseSceneProvider : ProviderBase
|
||||||
{
|
{
|
||||||
public readonly LoadSceneMode SceneMode;
|
public readonly LoadSceneMode SceneMode;
|
||||||
private readonly bool _activateOnLoad;
|
private readonly bool _activateOnLoad;
|
||||||
|
|
|
@ -4,7 +4,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal sealed class DatabaseSubAssetsProvider : AssetProviderBase
|
internal sealed class DatabaseSubAssetsProvider : ProviderBase
|
||||||
{
|
{
|
||||||
public override float Progress
|
public override float Progress
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal abstract class AssetProviderBase
|
internal abstract class ProviderBase
|
||||||
{
|
{
|
||||||
public enum EStatus
|
public enum EStatus
|
||||||
{
|
{
|
||||||
|
@ -88,7 +88,7 @@ namespace YooAsset
|
||||||
private readonly List<OperationHandleBase> _handles = new List<OperationHandleBase>();
|
private readonly List<OperationHandleBase> _handles = new List<OperationHandleBase>();
|
||||||
|
|
||||||
|
|
||||||
public AssetProviderBase(string assetPath, System.Type assetType)
|
public ProviderBase(string assetPath, System.Type assetType)
|
||||||
{
|
{
|
||||||
AssetPath = assetPath;
|
AssetPath = assetPath;
|
||||||
AssetName = System.IO.Path.GetFileName(assetPath);
|
AssetName = System.IO.Path.GetFileName(assetPath);
|
Loading…
Reference in New Issue