Update document

pull/4/head
hevinci 2022-04-07 12:05:21 +08:00
parent d8b1396641
commit efd0789e09
1 changed files with 29 additions and 0 deletions

View File

@ -121,3 +121,32 @@ IEnumerator Start()
} }
```` ````
**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;
string location = $"FairyRes/{name}{extension}";
var handle = YooAssets.LoadAssetSync(location , type);
_handles.Add(handle);
return handle.AssetObject;
}
// 释放资源句柄列表
private void ReleaseHandles()
{
foreach(var handle in _handles)
{
handle.Release();
}
_handles.Clear();
}
````