- Home /
3d platform tutorial game over text null refence error
I'm following the tutorial using Unity 3 and running the code provided at the end of this. This is the error code I am getting.
NullReferenceException: Object reference not set to an instance of an object Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args) UnityScript.Lang.UnityRuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args, System.Type scriptBaseType) GameOverGUI.OnGUI () (at Assets/GameOverGUI.js:13)
I'm trying to run this code...
@script ExecuteInEditMode()
var background : GUIStyle; var gameOverText : GUIStyle; var gameOverShadow : GUIStyle; var gameOverScale = 1.5; var gameOverShadowScale = 1.5;
function OnGUI()
{ GUI.Label(Rect((Screen.width - (Screen.height * 2))0.75,0,Screen.height 2,Screen.height),"",background);
GUI.matrix = GUI.Matrix4x4.TRS(Vector3(0,0,0),Quaternion.identity,Vector3.one
gameOverShadowScale); GUI.Label(Rect((Screen.width / (2 gameOverShadowScale)) - 150,(Screen.height/(2 gameOverShadowScale))- 40, 300, 100), "Game Over", gameOverShadow);
GUI.matrix = GUI.Matrix4x4.TRS(Vector3(0,0,0),Quaternion.identity,Vector3.one gameOverScale); GUI.Label(Rect((Screen.width / (2 gameOverScale)) - 150,(Screen.height/(2 * gameOverScale)) - 40, 300, 100), "Game Over", gameOverText);
}
line 13 is the GUI.matrix = GUI.Matrix4x4 etc. etc...
I have commented out this line and the line similar to it a few lines below and then it displays the text but it is not in the correct positioning.