- Home /
Possible Bug in Unity 5.4.1? NullReferenceException in console but everything works as expected (no old logs)
This is weird because everything works as expected.
I'm using a MovieTexture as a background of a Panel in the main menu of the game. Everything works, the MovieTexture plays and loops and the UI responds but this line gives NullReferenceException in console:
RawImage ri = this.gameObject.transform.FindChild ("RawImage").GetComponent<RawImage>();
MovieTexture t = ri.texture as MovieTexture;
t.loop = true;
t.Play ();
this refers to a MonoBehaviour that is component of the MainMenuPanel (a panel created in editor and then turned to prefab).
The first line is throwing:
NullReferenceException: Object reference not set to an instance of an object
MainMenu.Start ()
But everything just works. The game continues. The video plays. The buttons are clickable.
In case this may help to understand the problem this is the code that instantiate the prefab:
void showMainMenu () {
GameObject menu = Instantiate(Resources.Load<GameObject>("MainMenuPanel"));
menu.transform.SetParent (GameObject.Find ("Canvas").transform, false);
}
The function is called from MainScript.cs, attached to the MainCamera in the unique scene of the game. This is a single scene project. Level loading occurs from code.
Your answer
Follow this Question
Related Questions
Syncing separate video and audio 0 Answers
MovieTexture .ogg file size limit? 0 Answers
How to play Alpha video in unity ? 4 Answers
Video: Not ready to play yet 0 Answers
Null reference for variables(prefabs) when referencing another script 0 Answers