Casting from Texture to Texture2D returns null

Im trying to cast a Texture type to Texture 2D using the following code:

IEnumerator CreateVideoThumbnail(AVProWindowsMediaMovie movie)
        		Texture2D tex = (movie.OutputTexture) as Texture2D;;
        		while (tex == null)
        			tex = (movie.OutputTexture) as Texture2D;
        			yield return null;


The issue is that the variable tex never gets a value different from null and i have already tested it using a Debug.Log(movie.OutputTexture.width); in the loop, and it returns the correct texture width. (movie.OutputTexture is of type Texture)

The while loop is needed, since the movie would be loading just before trying to get, and it returns null for a few milliseconds, and then returns the Texture of the loaded video.

What I’m doing wrong?


I would imagine AVProWindowsMediaMovie.OutputTexture isn’t a Texture2D. Try adding this to see:

if (movie.OutputTexture is Texture2D)
  Debug.Log("Is a Texture2D");
  Debug.Log9"Is Not a Texture2D");

You’re probably best off going to the AVPro forums for this question.