mirror of https://github.com/tuyoogame/YooAsset
Update document
parent
d8b1396641
commit
efd0789e09
|
@ -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();
|
||||
}
|
||||
````
|
||||
|
||||
|
|
Loading…
Reference in New Issue