- Home /
Switch level script problem
alright so i have a switch level script. it was working fine but then i started getting these
NullReferenceException: Object reference not set to an instance of an object Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, System.Object[] args, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Object[] args, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory) Boo.Lang.Runtime.RuntimeServices.SetProperty (System.Object target, System.String name, System.Object value) Display GUI Script.Update () (at Assets/Misc Scripts/Display GUI Script.js:10)
errors.
this is the script i use:
var target : Transform;
function Update () {
var other = gameObject.GetComponent("GUI Style Script");
if ( Vector3.Distance(target.position, transform.position ) < 25) {
other.enabled = true;
}
if ( Vector3.Distance(target.position, transform.position ) > 25) {
other.enabled = false;
}
}
this script is used along with this script:
var level2load : int;
function OnGUI () {
// Make a background box
GUI.Box (Rect (10,10,300,90), "Do You Want To Go To the Next Level?");
// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
if (GUI.Button (Rect (130,40,80,20), "Yeah")) {
Application.LoadLevel(level2load);
}
}
i'm pretty sure the code wants to make my life miserable. =(
For starters, you really shouldn't have spaces in your filenames. I doubt that that is actually your problem though.
Your answer
![](https://koobas.hobune.stream/wayback/20220613063354im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Levels Loading Randomly 1 Answer
Run Script From Level to Level 1 Answer
how to make a game easier 2 Answers
Loading levels at runtime 1 Answer
One scene, many levels?? 2 Answers