Problem:
As stated in the title.
If anyone use handle’IsDone to get res & release res,will have problem(release not work)
Like:
https://github.com/Cysharp/UniTask/issues/112
Analytical:
- Example
AsyncOperationHandle InstantiateWithChain(AsyncOperationHandle dep, object key, InstantiationParameters instantiateParameters, bool trackHandle = true)
{
var chainOp = ResourceManager.CreateChainOperation(dep, op => InstantiateAsync(key, instantiateParameters, false));
if(trackHandle)
chainOp.CompletedTypeless += m_OnHandleCompleteAction;
return chainOp;
}
Sugess:
when create AsyncOperationHandle,should check Handle is Done and add obj&handle to m_resultToHandle immediately.
- Example
AsyncOperationHandle InstantiateWithChain(AsyncOperationHandle dep, object key, InstantiationParameters instantiateParameters, bool trackHandle = true)
{
var chainOp = ResourceManager.CreateChainOperation(dep, op => InstantiateAsync(key, instantiateParameters, false));
if(trackHandle)
{
if(chainOp.IsDone)
{
if (!m_resultToHandle.ContainsKey(handle.Result))
{
handle.Destroyed += m_OnHandleDestroyedAction;
m_resultToHandle.Add(handle.Result, handle);
}
}
else
{
chainOp.CompletedTypeless += m_OnHandleCompleteAction;
}
}
return chainOp;
}