Update AssetSystem
parent
829b4fca76
commit
6f6ecf845a
|
@ -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>
|
||||||
/// 等待异步执行完毕
|
/// 等待异步执行完毕
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -95,5 +69,57 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
this.ReleaseInternal();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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>
|
||||||
/// 获取子资源对象
|
/// 获取子资源对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -70,23 +89,5 @@ namespace YooAsset
|
||||||
YooLogger.Warning($"Not found sub asset {assetName} in {_provider.AssetPath}");
|
YooLogger.Warning($"Not found sub asset {assetName} in {_provider.AssetPath}");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 等待异步执行完毕
|
|
||||||
/// </summary>
|
|
||||||
public void WaitForAsyncComplete()
|
|
||||||
{
|
|
||||||
if (IsValid == false)
|
|
||||||
return;
|
|
||||||
_provider.WaitForAsyncComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 释放资源句柄
|
|
||||||
/// </summary>
|
|
||||||
public void Release()
|
|
||||||
{
|
|
||||||
this.ReleaseInternal();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue