mirror of https://github.com/tuyoogame/YooAsset
Update document
parent
a7993efeda
commit
083c7af361
|
@ -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)
|
||||
|
|
|
@ -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)
|
|
@ -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)
|
||||
|
||||
## 视频教程
|
||||
|
||||
|
|
Loading…
Reference in New Issue