- Home /
One of my scripts has no check-box next to it in Inspector
I have created an empty gameobject and dragged four scripts onto it to control various things. One of them has no check-box next to it in the inspector and one of the others isn't being instantiated properly, meaning I'm getting an error:
NullReferenceException: Object reference not set to an instance of an object
I am referencing them like this:
public class DataLayer : MonoBehaviour { private Configs configOb; private PageLoader pl;
 
               void Start() { configOb = (Configs)gameObject.GetComponent(typeof(Configs)); //configOb = new Configs(); //pl = new PageLoader(); pl = (PageLoader)gameObject.GetComponent(typeof(PageLoader)); }
 public ArrayList getTopApps() { ArrayList titleArray = new ArrayList(); string fetchUrl = configOb.getRoot()+"TopTen.php"; 
When I test this code it fails at the bottom line because the configOb is null.
I am having the exact same problem! while my scripting was working fine it stoped and i get the exact same message! and there is no tick box! what should i do?
Answer by runevision · Nov 18, 2009 at 01:49 PM
Your MonoBehaviour won't have a checkbox next to it in the inspector if it doesn't have any of the per-frame methods, like Update, FixedUpdate, OnGUI, etc.
I can't tell you why your configOb variable isn't being set properly. It may be due to something outside of the script you posted.
Ok, thanks. I can't figure out why it wont initiate my scripts
Answer by Jormungandr · Nov 18, 2009 at 06:11 PM
Is getTopApps() called by another script's Start() method? If so, it may be running before DataLayer.Start() is.
The convention I usually follow to avoid this is to put all reference assignment (GetComponent, Find, etc) in Awake, while startup functionality that relies on such references always goes in Start.
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                