Hi Unity Community
I am trying to access a script from a gameobject when loading a level (hence not able to assign in inspector) and keep getting null references thrown at me; I have used the go.find().getcomponent() method numerous times and never encountered an issue so I am kind of stumped as to why this is occurring?
Have tried a number of different formulations for accessing the script but to no avail, can anyone provide me any pointers as to where I am going wrong? [Scripting in uJS]
Many thanks in advance,
Ryan
Script To Access:
Current Code:
var rayDetectScript : BrowseRayDetectObj;
var browseXml : BrowseContextInfoXml;
function editViewInfo()
{
var curObj : GameObject = rayDetectScript.curObj;
loadImportCurObj(curObj);
}
function loadImportCurObj(curObj : GameObject){
//used to load import scene to view full info of selected browse obj
//cur obj needs to persist between scenes
Application.LoadLevel("MetaPipe_ImportScene");
DontDestroyOnLoad(curObj);
curObj.tag = "Current Model";
curObj.transform.position = Vector3(0, 0, 0);
var gameController = GameObject.Find("GameController");
//var infoCont : ObjInfoControl = gameController.GetComponent.<ObjInfoControl>();
//var infoCont : ObjInfoControl = gameController.GetComponent("Obj Info Control");
var infoCont : ObjInfoControl = gameController.GetComponent(ObjInfoControl);
infoCont.fileName = browseXml.fileName;
infoCont.Load();
}