Unity3d。使用视频播放器渲染纹理
Unity3d. RenderTexture with Video Player
在场景中创建(实例化)对象时,在自定义脚本(MonoBehaviour)脚本中,创建了一个RendereTexture对象,这个对象销毁后,RendererTexture的内存是否也被释放了?
您可以打开 Profiler 并自己简单地进行测试。
剧透:我想不是。
Afaik any Texture
不会自动被 GC 收集,但需要显式销毁
如果你想确定你可以简单地做例如
private void OnDestroy()
{
if(renderTextureReference) Destroy(renderTextureReference);
}
在你的组件中。
This function releases the hardware resources used by the render texture. The texture itself is not destroyed, and will be automatically created again when being used.
As with other "native engine object" types, it is important to pay attention to the lifetime of any render textures and release them when you are finished using them, as they will not be garbage collected like normal managed types.
在场景中创建(实例化)对象时,在自定义脚本(MonoBehaviour)脚本中,创建了一个RendereTexture对象,这个对象销毁后,RendererTexture的内存是否也被释放了?
您可以打开 Profiler 并自己简单地进行测试。
剧透:我想不是。
Afaik any Texture
不会自动被 GC 收集,但需要显式销毁
如果你想确定你可以简单地做例如
private void OnDestroy()
{
if(renderTextureReference) Destroy(renderTextureReference);
}
在你的组件中。
This function releases the hardware resources used by the render texture. The texture itself is not destroyed, and will be automatically created again when being used.
As with other "native engine object" types, it is important to pay attention to the lifetime of any render textures and release them when you are finished using them, as they will not be garbage collected like normal managed types.