Update document

pull/31/head
hevinci 2022-08-01 11:51:35 +08:00
parent a7993efeda
commit 083c7af361
3 changed files with 38 additions and 35 deletions

View File

@ -180,38 +180,3 @@ private GetAssetInfosByTag(string tag)
} }
```` ````
**FairyGUI支持解决方案**
注意在FairyGUI的面板销毁的时候将资源句柄列表释放否则会造成资源泄漏。
````c#
// 资源句柄列表
private List<AssetOperationHandle> _handles = new List<AssetOperationHandle>(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)

37
Docs/CodeTutorial4.md Normal file
View File

@ -0,0 +1,37 @@
# 解决方案
**FairyGUI支持解决方案**
注意在FairyGUI的面板销毁的时候将资源句柄列表释放否则会造成资源泄漏。
````c#
// 资源句柄列表
private List<AssetOperationHandle> _handles = new List<AssetOperationHandle>(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)

View File

@ -60,6 +60,7 @@
1. [初始化](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial1.md) 1. [初始化](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial1.md)
2. [资源更新](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial2.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/CodeTutorial3.md)
3. [解决方案](https://github.com/tuyoogame/YooAsset/blob/master/Docs/CodeTutorial4.md)
## 视频教程 ## 视频教程