I want to use the Native Texture in WP8 (Unity 4.3.4),
I have created an texture in the native code, and use Texture2D.CreateExternalTexture to use this texture in Unity.
but the big issue is how to release the texture:
- it look like the “UnityEngine.Object.Destroy(theTexure)” does not release the real texture, in my test, the program would crash because of low memory.
- if I called the ID3D11Texture2D->Release and ID3D11ShaderResourceView->Release in the Native Code when release the texture,
the Program will crash later at
D3D11.DLL!CContext::ID3D11DeviceContext1_SetShaderResources_<5,4>(struct ID3D11DeviceContext1 *,unsigned int,unsigned int,struct ID3D11ShaderResourceView * const *)it seems that the Unity continue use the texture after it has been released, I have tried to delay 10 frames to call the native release function, but that won’t fix the issue.
there is also another issue about the Native Texture:
When the App return from pause, the ID3D11Device seems need to be recreated, and the Native Texture should also be recreated, in my program, I just recreated the texture in native code and use Texture2D.UpdateExternalTexture to update the unity Texture, it seems work mostly, but some time the program crash…
so here are my two issues:
- how to release the native created texture in unity,
- how to deal with the native texture when the app returned from pause.
Any One knows how to resolve them?
Thank you!