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