i really don’t understand why this error come to me so much times x.x
i could handle it 2-3 times, but now i can’t handle it again… although i have build the exact same code with the last one…
so my code is guiSchool3.js (This script attached to Main Camera on Scene “A”)
#pragma strict
var script : guiSchool2;
var choice : int;
script = GetComponent(guiSchool2);
choice = script.flag;
var tekstur1 : Texture;
function Start () {
}
function OnGUI(){
if(choice==1){
GUI.DrawTexture(Rect(Screen.width*0.125,Screen.height*0.125,Screen.width*0.75,Screen.height*0.75),tekstur1);
}
else if (choice==2){
}
}
and here’s guiSchool2! (i delete the part that not linked by the error)(This Script attached to Main Camera on Scene “B”)
#pragma strict
var flag: int;
function OnGUI (){
GUI.DrawTexture(Rect(posbg_w,posbg_h,bg_w,bg_h),bg);
if(GUI.Button(Rect(pos_b1w,pos_b1h,b_width,b_height)," ",button_perkalian)){
flag = 1;
Application.LoadLevel("School3");
}
if(GUI.Button(Rect(pos_b1w,pos_b2h,b_width,b_height)," ",button_luas)){
flag = 2;
Application.LoadLevel("School3");
}
if(GUI.Button(Rect(pos_b1w,pos_b3h,b_width,b_height)," ",button_satuan)){
flag = 3;
Application.LoadLevel("School3");
}
}
and the console throw me this exception
NullReferenceException: Object reference not set to an instance of an object
guiSchool3.Main () (at Assets/Scripts/School/guiSchool3.js:5)
i believe i’ve done the exact same with the code before… but it’s still wrong… why?