Hey everyone. Currently I'm trying to have a video play in fullscreen, lock the cursor, etc. Everything that you'd expect for a cutscene/that sort of thing. I've looked at various tutorials as far as this goes, and between mixing different tutorials together to try and get it to work- I've got my code, however it throws the following error:
**"NullReferenceException: Object reference not set to an instance of an object
UnityEngine.GUI.DrawTexture (Rect position, UnityEngine.Texture image, ScaleMode scaleMode, Boolean alphaBlend, Single imageAspect)
UnityEngine.GUI.DrawTexture (Rect position, UnityEngine.Texture image)
ShouldPlay.onGUI () (at Assets/Custom Assets/Scripts/MainMenu/Scripts/ShouldPlay.js:29)"**
var shouldPlay : boolean = false;
var VideoTexture : MovieTexture;
function Start () {
}
function Update () {
}
function ShouldPlay (shouldPlay : boolean) {
if (shouldPlay) {
onGUI();
Screen.fullScreen = true;
Screen.showCursor = false;
VideoTexture.Play();
}
}
function onGUI () {
GUI.DrawTexture(Rect(0,0,Screen.width,Screen.height),VideoTexture,ScaleMode.ScaleToFit); // IMPORTANT: This is the line the code error leads to.
}
I feel I should also mention I use .SendMessage to trigger the shouldPlay boolean to true.
↧
Help playing movie ~ (NullReferenceException: Object reference not set to an instance of an object)
↧