- Home /
Question by
Tibor-Udvari · Sep 06, 2015 at 12:39 PM ·
2dspritetexture2dmovietexture
Unity UpdateExternalTexture from MovieTexture windows crash
I'm trying to play a MovieTexture object with a SpriteRenderer object. My code is working fine on OSX.
It crashes my windows 7 exported game, and play mode in Unity editor in windows 7.
I am sure the currentTexture.UpdateExternalTexture() call is making it crash, but I can't figure out why.
Can anybody explain why this is not working or how to debug it? The Unity log file didn't contain anything that seemed useful, just the message Crashed.
Here is what I am using
using UnityEngine;
using System.Collections;
public class FMAC_VideoPlayer : MonoBehaviour {
public string animationName = "escalator";
MovieTexture movieTexture;
Texture2D currentTexture;
SpriteRenderer spriteRenderer;
Sprite sprite;
void Start ()
{
movieTexture = Resources.Load (animationName) as MovieTexture;
currentTexture = new Texture2D(movieTexture.width, movieTexture.height);
currentTexture.UpdateExternalTexture(movieTexture.GetNativeTexturePtr());
spriteRenderer = GetComponent<SpriteRenderer> ();
sprite = Sprite.Create (currentTexture, new Rect(Vector2.zero, new Vector2(movieTexture.width, movieTexture.height)), new Vector2(0.5f, 0.5f));
spriteRenderer.sprite = sprite;
movieTexture.Play();
}
}
Comment