mirror of https://github.com/tuyoogame/YooAsset
Update runtime code
移除了YooAssets.IsInitialized字段 增加了YooAssets.InitializeStatus字段pull/51/head
parent
1de9e0b79d
commit
c2192dd657
|
@ -25,11 +25,11 @@ namespace YooAsset
|
|||
public string PackageName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经初始化
|
||||
/// 初始化状态
|
||||
/// </summary>
|
||||
public bool IsInitialized
|
||||
public EOperationStatus InitializeStatus
|
||||
{
|
||||
get { return _isInitialize; }
|
||||
get { return _initializeStatus; }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,17 +17,18 @@ namespace YooAsset
|
|||
public static void Initialize()
|
||||
{
|
||||
if (_isInitialize)
|
||||
throw new Exception("YooAssets is initialized !");
|
||||
throw new Exception($"{nameof(YooAssets)} is initialized !");
|
||||
|
||||
// 创建驱动器
|
||||
if (_isInitialize == false)
|
||||
{
|
||||
// 创建驱动器
|
||||
_isInitialize = true;
|
||||
UnityEngine.GameObject driverGo = new UnityEngine.GameObject("[YooAsset]");
|
||||
UnityEngine.GameObject driverGo = new UnityEngine.GameObject($"[{nameof(YooAssets)}]");
|
||||
driverGo.AddComponent<YooAssetDriver>();
|
||||
UnityEngine.Object.DontDestroyOnLoad(driverGo);
|
||||
|
||||
#if DEBUG
|
||||
// 添加远程调试脚本
|
||||
driverGo.AddComponent<RemoteDebuggerInRuntime>();
|
||||
#endif
|
||||
|
||||
|
@ -83,7 +84,7 @@ namespace YooAsset
|
|||
public static YooAssetPackage CreateAssetPackage(string packageName)
|
||||
{
|
||||
if (_isInitialize == false)
|
||||
throw new Exception("YooAssets not initialize !");
|
||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new Exception("PackageName is null or empty !");
|
||||
|
@ -96,12 +97,37 @@ namespace YooAsset
|
|||
return component;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包
|
||||
/// </summary>
|
||||
/// <param name="packageName">资源包名称</param>
|
||||
public static YooAssetPackage GetAssetPackage(string packageName)
|
||||
{
|
||||
if (_isInitialize == false)
|
||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new Exception("Package name is null or empty !");
|
||||
|
||||
foreach (var package in _packages)
|
||||
{
|
||||
if (package.PackageName == packageName)
|
||||
return package;
|
||||
}
|
||||
|
||||
YooLogger.Warning($"Not found asset package : {packageName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测资源包是否存在
|
||||
/// </summary>
|
||||
/// <param name="packageName">资源包名称</param>
|
||||
public static bool HasAssetPackage(string packageName)
|
||||
{
|
||||
if (_isInitialize == false)
|
||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||
|
||||
foreach (var package in _packages)
|
||||
{
|
||||
if (package.PackageName == packageName)
|
||||
|
|
|
@ -11,18 +11,19 @@ namespace YooAsset
|
|||
private static YooAssetPackage _mainPackage;
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经初始化
|
||||
/// 初始化状态
|
||||
/// </summary>
|
||||
public static bool IsInitialized
|
||||
public static EOperationStatus InitializeStatus
|
||||
{
|
||||
get
|
||||
get
|
||||
{
|
||||
if (_mainPackage == null)
|
||||
return false;
|
||||
return _mainPackage.IsInitialized;
|
||||
return EOperationStatus.None;
|
||||
return _mainPackage.InitializeStatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue