From 6f6ecf845aa2ec62650f1620f02ccd7e738e9ae4 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 23 Mar 2022 14:58:13 +0800 Subject: [PATCH] Update AssetSystem --- .../Handles/AssetOperationHandle.cs | 78 ++++++++++++------- .../Handles/SubAssetsOperationHandle.cs | 37 ++++----- 2 files changed, 71 insertions(+), 44 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs index 97ba1ac..7c795ae 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/AssetOperationHandle.cs @@ -52,32 +52,6 @@ namespace YooAsset } } - /// - /// 同步初始化游戏对象 - /// - 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); - } - - /// - /// 异步初始化游戏对象 - /// - public InstantiateOperation InstantiateAsync(Vector3 position, Quaternion rotation, Transform parent = null) - { - InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent); - OperationSystem.ProcessOperaiton(operation); - return operation; - } - /// /// 等待异步执行完毕 /// @@ -95,5 +69,57 @@ namespace YooAsset { this.ReleaseInternal(); } + + + /// + /// 同步初始化游戏对象 + /// + /// 父类对象 + /// + public GameObject InstantiateSync(Transform parent = null) + { + return InstantiateSync(Vector3.zero, Quaternion.identity, parent); + } + + /// + /// 同步初始化游戏对象 + /// + /// 坐标 + /// 角度 + /// 父类对象 + 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); + } + + /// + /// 异步初始化游戏对象 + /// + /// 父类对象 + public InstantiateOperation InstantiateAsync(Transform parent = null) + { + return InstantiateAsync(Vector3.zero, Quaternion.identity, parent); + } + + /// + /// 异步初始化游戏对象 + /// + /// 坐标 + /// 角度 + /// 父类对象 + public InstantiateOperation InstantiateAsync(Vector3 position, Quaternion rotation, Transform parent = null) + { + InstantiateOperation operation = new InstantiateOperation(this, position, rotation, parent); + OperationSystem.ProcessOperaiton(operation); + return operation; + } } } \ No newline at end of file diff --git a/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs b/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs index 9443f6b..f71f28d 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Handles/SubAssetsOperationHandle.cs @@ -51,6 +51,25 @@ namespace YooAsset } } + /// + /// 等待异步执行完毕 + /// + public void WaitForAsyncComplete() + { + if (IsValid == false) + return; + _provider.WaitForAsyncComplete(); + } + + /// + /// 释放资源句柄 + /// + public void Release() + { + this.ReleaseInternal(); + } + + /// /// 获取子资源对象 /// @@ -70,23 +89,5 @@ namespace YooAsset YooLogger.Warning($"Not found sub asset {assetName} in {_provider.AssetPath}"); return null; } - - /// - /// 等待异步执行完毕 - /// - public void WaitForAsyncComplete() - { - if (IsValid == false) - return; - _provider.WaitForAsyncComplete(); - } - - /// - /// 释放资源句柄 - /// - public void Release() - { - this.ReleaseInternal(); - } } } \ No newline at end of file