Update asset system
parent
72a49d0ed8
commit
e9af0c7042
|
@ -87,7 +87,7 @@ namespace YooAsset
|
|||
/// <returns></returns>
|
||||
public GameObject InstantiateSync(Transform parent = null)
|
||||
{
|
||||
return InstantiateSyncInternal(Vector3.zero, Quaternion.identity, parent, false);
|
||||
return InstantiateSyncInternal(Vector3.zero, Quaternion.identity, parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -98,7 +98,7 @@ namespace YooAsset
|
|||
/// <param name="parent">父类对象</param>
|
||||
public GameObject InstantiateSync(Vector3 position, Quaternion rotation, Transform parent = null)
|
||||
{
|
||||
return InstantiateSyncInternal(position, rotation, parent, true);
|
||||
return InstantiateSyncInternal(position, rotation, parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -107,7 +107,7 @@ namespace YooAsset
|
|||
/// <param name="parent">父类对象</param>
|
||||
public InstantiateOperation InstantiateAsync(Transform parent = null)
|
||||
{
|
||||
return InstantiateAsyncInternal(Vector3.zero, Quaternion.identity, parent, false);
|
||||
return InstantiateAsyncInternal(Vector3.zero, Quaternion.identity, parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -118,37 +118,23 @@ namespace YooAsset
|
|||
/// <param name="parent">父类对象</param>
|
||||
public InstantiateOperation InstantiateAsync(Vector3 position, Quaternion rotation, Transform parent = null)
|
||||
{
|
||||
return InstantiateAsyncInternal(position, rotation, parent, true);
|
||||
return InstantiateAsyncInternal(position, rotation, parent);
|
||||
}
|
||||
|
||||
|
||||
private GameObject InstantiateSyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
|
||||
private GameObject InstantiateSyncInternal(Vector3 position, Quaternion rotation, Transform parent)
|
||||
{
|
||||
if (IsValid == false)
|
||||
return null;
|
||||
if (Provider.AssetObject == null)
|
||||
return null;
|
||||
|
||||
GameObject result;
|
||||
if (setPositionRotation)
|
||||
{
|
||||
if (parent == null)
|
||||
result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation);
|
||||
else
|
||||
result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation, parent);
|
||||
GameObject clone = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, position, rotation, parent);
|
||||
return clone;
|
||||
}
|
||||
else
|
||||
private InstantiateOperation InstantiateAsyncInternal(Vector3 position, Quaternion rotation, Transform parent)
|
||||
{
|
||||
if (parent == null)
|
||||
result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject);
|
||||
else
|
||||
result = UnityEngine.Object.Instantiate(Provider.AssetObject as GameObject, parent);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private InstantiateOperation InstantiateAsyncInternal(Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
|
||||
{
|
||||
InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent, setPositionRotation);
|
||||
InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent);
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace YooAsset
|
|||
private readonly Vector3 _position;
|
||||
private readonly Quaternion _rotation;
|
||||
private readonly Transform _parent;
|
||||
private readonly bool _setPositionRotation;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
|
@ -24,13 +23,12 @@ namespace YooAsset
|
|||
public GameObject Result = null;
|
||||
|
||||
|
||||
internal InstantiateOperation(AssetOperationHandle handle, Vector3 position, Quaternion rotation, Transform parent, bool setPositionRotation)
|
||||
internal InstantiateOperation(AssetOperationHandle handle, Vector3 position, Quaternion rotation, Transform parent)
|
||||
{
|
||||
_handle = handle;
|
||||
_position = position;
|
||||
_rotation = rotation;
|
||||
_parent = parent;
|
||||
_setPositionRotation = setPositionRotation;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
|
@ -62,20 +60,8 @@ namespace YooAsset
|
|||
return;
|
||||
}
|
||||
|
||||
if (_setPositionRotation)
|
||||
{
|
||||
if (_parent == null)
|
||||
Result = Object.Instantiate(_handle.AssetObject as GameObject, _position, _rotation);
|
||||
else
|
||||
// 实例化游戏对象
|
||||
Result = Object.Instantiate(_handle.AssetObject as GameObject, _position, _rotation, _parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_parent == null)
|
||||
Result = Object.Instantiate(_handle.AssetObject as GameObject);
|
||||
else
|
||||
Result = Object.Instantiate(_handle.AssetObject as GameObject, _parent);
|
||||
}
|
||||
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
|
@ -94,5 +80,16 @@ namespace YooAsset
|
|||
Error = $"User cancelled !";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等待异步实例化结束
|
||||
/// </summary>
|
||||
public void WaitForAsyncComplete()
|
||||
{
|
||||
if (_steps == ESteps.Done)
|
||||
return;
|
||||
_handle.WaitForAsyncComplete();
|
||||
Update();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@ namespace YooAsset
|
|||
{
|
||||
/// <summary>
|
||||
/// 编辑器下的模拟模式
|
||||
/// 注意:在初始化的时候自动构建真机模拟环境。
|
||||
/// </summary>
|
||||
EditorSimulateMode,
|
||||
|
||||
|
|
Loading…
Reference in New Issue