Texture2D.CreateExternalTexture and Texture2D.UpdateExternalTexture?

Can some one please provide example code on how to use Texture2D.CreateExternalTexture and Texture2D.UpdateExternalTexture with DX11? Also, DOES UNITY ANSWER ANYTHING IN THIS FORUM? I have posted 3 threads related to this issue and there is no reply to anything!!!

In the unity manuals it says:

Description
Creates Unity Texture on top of already inited native texture object.

What is inited??

Whoa, I’m going to play with this right now. Do you think we can point it at the texture id of a camera feed or decoded video feed made natively on mobile?

Inited == Initialised.

This is mostly a community forum. A number of us Unity-peeps keep an eye on the site and try and help out where we can.

To answer you real question, no, I don’t have a code example. The basic idea is that you’ll have a native code plugin that does something with DX11, most likely creating textures. You’d pass a System.IntPtr from the plugin into the Unity script code and call Texture2D.CreateExternalTexture. Unity then fakes up a Texture2D for you to use in your script code, but, in reality, it’s using your texture from your plugin. As an when you’d want this texture to change, you would call UpdateExternalTexture on it, passing in a new IntPtr from your plugin.

There’s an example that does something similar, but different, here:

http://docs.unity3d.com/Documentation/Manual/NativePluginInterface.html

This shows how your native plugin can do rendering, and passes Unity-created Texture2Ds to the plugin, so works in the opposite direction.

Will Texture2D.CreateExternalTexture work on IOS or Android?

Reason for asking is because
Note: The rendering callbacks to plugins are not currently supported on mobile platforms.”

Cheers.

@Graham,

I’m kind a confused about:
“You’d pass a System.IntPtr from the plugin into the Unity script code and call Texture2D.CreateExternalTexture”

From the example project at the bottom of Unity - Manual: Low-level native plug-in interface,
I thought that System.IntPtr is created inside of unity script and then sent to the Plugin.

How can I create a System.IntPtr from the plugin ?

Hi
When creating texture with CreateExternalTexture I get something like 5 or 6 ms of GFXWaitForPresent why this is happening? The texture is already created on the native side and uploaded to the GPU if I’m not wrong.
I’m using D3D11.
So please can you explain me what going on