From cecbb35f1a5f19389a5bc576a47b372584ede8bd Mon Sep 17 00:00:00 2001 From: hevinci Date: Mon, 1 Aug 2022 11:54:48 +0800 Subject: [PATCH] Update document --- Docs/CodeTutorial4.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/Docs/CodeTutorial4.md b/Docs/CodeTutorial4.md index 4e9d26c..423554c 100644 --- a/Docs/CodeTutorial4.md +++ b/Docs/CodeTutorial4.md @@ -1,6 +1,6 @@ # 解决方案 -**FairyGUI支持解决方案** +### FairyGUI支持解决方案 注意:在FairyGUI的面板销毁的时候,将资源句柄列表释放,否则会造成资源泄漏。 @@ -32,6 +32,24 @@ private void ReleaseHandles() } ```` -**UniTask支持解决方案** +### UniTask支持解决方案 -[解决方案](https://github.com/tuyoogame/YooAsset/blob/master/Assets/YooAsset/Samples~/UniTask Sample/README.md) +[仓库链接](https://github.com/Cysharp/UniTask) + +- 请去下载对应的源码,并删除此目录最后的波浪线 +- 在项目的 `asmdef` 文件中添加对 `UniTask.YooAsset` 的引用 +- 在 UniTask `_InternalVisibleTo.cs` 文件中增加 `[assembly: InternalsVisibleTo("UniTask.YooAsset")]` 后即可使用 + +代码示例 + +```csharp +var handle = YooAssets.LoadAssetAsync("Assets/Res/Prefabs/TestImg.prefab"); + +await handle.ToUniTask(); + +var obj = handle.AssetObject as GameObject; +var go = Instantiate(obj, transform); + +go.transform.localPosition = Vector3.zero; +go.transform.localScale = Vector3.one; +```