From 083c7af361b28aa3c68e7f012f2aba564864ef1f Mon Sep 17 00:00:00 2001 From: hevinci Date: Mon, 1 Aug 2022 11:51:35 +0800 Subject: [PATCH] Update document --- Docs/CodeTutorial3.md | 35 ----------------------------------- Docs/CodeTutorial4.md | 37 +++++++++++++++++++++++++++++++++++++ README.md | 1 + 3 files changed, 38 insertions(+), 35 deletions(-) create mode 100644 Docs/CodeTutorial4.md diff --git a/Docs/CodeTutorial3.md b/Docs/CodeTutorial3.md index 153d20b..27b5274 100644 --- a/Docs/CodeTutorial3.md +++ b/Docs/CodeTutorial3.md @@ -180,38 +180,3 @@ private GetAssetInfosByTag(string tag) } ```` -**FairyGUI支持解决方案** - -注意:在FairyGUI的面板销毁的时候,将资源句柄列表释放,否则会造成资源泄漏。 - -````c# -// 资源句柄列表 -private List _handles = new List(100); - -// 加载方法 -private object LoadFunc(string name, string extension, System.Type type, out DestroyMethod method) -{ - method = DestroyMethod.None; //注意:这里一定要设置为None - string location = $"FairyRes/{name}{extension}"; - var handle = YooAssets.LoadAssetSync(location , type); - _handles.Add(handle); - return handle.AssetObject; -} - -// 执行FairyGUI的添加包函数 -UIPackage.AddPackage(name, LoadFunc); - -// 释放资源句柄列表 -private void ReleaseHandles() -{ - foreach(var handle in _handles) - { - handle.Release(); - } - _handles.Clear(); -} -```` - -**UniTask支持解决方案** - -[解决方案](https://github.com/tuyoogame/YooAsset/blob/master/Assets/YooAsset/Samples~/UniTaskSample/README.md) diff --git a/Docs/CodeTutorial4.md b/Docs/CodeTutorial4.md new file mode 100644 index 0000000..4e9d26c --- /dev/null +++ b/Docs/CodeTutorial4.md @@ -0,0 +1,37 @@ +# 解决方案 + +**FairyGUI支持解决方案** + +注意:在FairyGUI的面板销毁的时候,将资源句柄列表释放,否则会造成资源泄漏。 + +````c# +// 资源句柄列表 +private List _handles = new List(100); + +// 加载方法 +private object LoadFunc(string name, string extension, System.Type type, out DestroyMethod method) +{ + method = DestroyMethod.None; //注意:这里一定要设置为None + string location = $"FairyRes/{name}{extension}"; + var handle = YooAssets.LoadAssetSync(location , type); + _handles.Add(handle); + return handle.AssetObject; +} + +// 执行FairyGUI的添加包函数 +UIPackage.AddPackage(name, LoadFunc); + +// 释放资源句柄列表 +private void ReleaseHandles() +{ + foreach(var handle in _handles) + { + handle.Release(); + } + _handles.Clear(); +} +```` + +**UniTask支持解决方案** + +[解决方案](https://github.com/tuyoogame/YooAsset/blob/master/Assets/YooAsset/Samples~/UniTask Sample/README.md) diff --git a/README.md b/README.md index bc030b7..37490c7 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ 1. [初始化](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial1.md) 2. [资源更新](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial2.md) 3. [资源加载](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial3.md) +3. [解决方案](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial4.md) ## 视频教程