Version: 2020.2

Texture.GetNativeTexturePtr

切换到手册
public IntPtr GetNativeTexturePtr ();

返回

IntPtr 指向底层图形 API 纹理资源的指针。

描述

获取指向纹理资源的原生(底层图形 API)指针。

使用此函数可检索与特定纹理对应的指针/句柄, 因为它以原生图形 API 级别表示。 这可用于通过 native code plugins 启用纹理操作。

注意:使用 Unity API 修改纹理对象的像素数据时,会更改基础图形 API 原生指针。调用 GetNativeTexturePtr 可获取新的原生指针。

For specific platforms, Unity has the following specifications: On Direct3D-like devices, Unity returns a pointer to the base texture type (IDirect3DBaseTexture9 on D3D9, ID3D11Resource on D3D11, ID3D12Resource on D3D12). On OpenGL-like devices, the GL texture "name" is returned; cast the pointer to an integer type to get it. On Metal, Unity returns an id<MTLTexture> pointer. On Vulkan, Unity returns an VkImage pointer. On platforms that do not support native code plug-ins, this function always returns NULL. 注意,在使用多线程渲染时调用此函数将与正在渲染的线程(慢速操作)同步, 因此最佳做法是仅在初始化时设置所需的 纹理指针。

另请参阅:原生代码插件Texture2D.CreateExternalTextureCubemap.CreateExternalTextureRenderTexture.GetNativeDepthBufferPtr

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961