Update AssetSystem

pull/4/head
hevinci 2022-03-23 14:58:13 +08:00
parent 829b4fca76
commit 6f6ecf845a
2 changed files with 71 additions and 44 deletions

View File

@ -52,32 +52,6 @@ namespace YooAsset
}
}
/// <summary>
/// 同步初始化游戏对象
/// </summary>
public GameObject InstantiateSync(Vector3 position, Quaternion rotation, Transform parent = null)
{
if (IsValid == false)
return null;
if (_provider.AssetObject == null)
return null;
if (parent == null)
return UnityEngine.Object.Instantiate(_provider.AssetObject as GameObject, position, rotation);
else
return UnityEngine.Object.Instantiate(_provider.AssetObject as GameObject, position, rotation, parent);
}
/// <summary>
/// 异步初始化游戏对象
/// </summary>
public InstantiateOperation InstantiateAsync(Vector3 position, Quaternion rotation, Transform parent = null)
{
InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent);
OperationSystem.ProcessOperaiton(operation);
return operation;
}
/// <summary>
/// 等待异步执行完毕
/// </summary>
@ -95,5 +69,57 @@ namespace YooAsset
{
this.ReleaseInternal();
}
/// <summary>
/// 同步初始化游戏对象
/// </summary>
/// <param name="parent">父类对象</param>
/// <returns></returns>
public GameObject InstantiateSync(Transform parent = null)
{
return InstantiateSync(Vector3.zero, Quaternion.identity, parent);
}
/// <summary>
/// 同步初始化游戏对象
/// </summary>
/// <param name="position">坐标</param>
/// <param name="rotation">角度</param>
/// <param name="parent">父类对象</param>
public GameObject InstantiateSync(Vector3 position, Quaternion rotation, Transform parent = null)
{
if (IsValid == false)
return null;
if (_provider.AssetObject == null)
return null;
if (parent == null)
return UnityEngine.Object.Instantiate(_provider.AssetObject as GameObject, position, rotation);
else
return UnityEngine.Object.Instantiate(_provider.AssetObject as GameObject, position, rotation, parent);
}
/// <summary>
/// 异步初始化游戏对象
/// </summary>
/// <param name="parent">父类对象</param>
public InstantiateOperation InstantiateAsync(Transform parent = null)
{
return InstantiateAsync(Vector3.zero, Quaternion.identity, parent);
}
/// <summary>
/// 异步初始化游戏对象
/// </summary>
/// <param name="position">坐标</param>
/// <param name="rotation">角度</param>
/// <param name="parent">父类对象</param>
public InstantiateOperation InstantiateAsync(Vector3 position, Quaternion rotation, Transform parent = null)
{
InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent);
OperationSystem.ProcessOperaiton(operation);
return operation;
}
}
}

View File

@ -51,6 +51,25 @@ namespace YooAsset
}
}
/// <summary>
/// 等待异步执行完毕
/// </summary>
public void WaitForAsyncComplete()
{
if (IsValid == false)
return;
_provider.WaitForAsyncComplete();
}
/// <summary>
/// 释放资源句柄
/// </summary>
public void Release()
{
this.ReleaseInternal();
}
/// <summary>
/// 获取子资源对象
/// </summary>
@ -70,23 +89,5 @@ namespace YooAsset
YooLogger.Warning($"Not found sub asset {assetName} in {_provider.AssetPath}");
return null;
}
/// <summary>
/// 等待异步执行完毕
/// </summary>
public void WaitForAsyncComplete()
{
if (IsValid == false)
return;
_provider.WaitForAsyncComplete();
}
/// <summary>
/// 释放资源句柄
/// </summary>
public void Release()
{
this.ReleaseInternal();
}
}
}