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;
}
CreateThumbnail(tex);
}
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?
Thanks!