• Unity
  • Services
  • Made with Unity
  • Learn
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Forums
  • Answers
  • Feedback
  • Issue Tracker
  • Blog
  • Evangelists
  • User Groups

Navigation

  • Home
  • Unity
  • Industries
  • Made with Unity
  • Learn
  • Community
    • Forums
    • Answers
    • Feedback
    • Issue Tracker
    • Blog
    • Evangelists
    • User Groups
  • Get Unity
  • Asset Store

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Ben Gannaway · Nov 18, 2009 at 11:17 AM · mono-behaviour

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.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image stilos · Feb 27, 2015 at 11:51 PM 0
Share

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?

2 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ben Gannaway · Nov 18, 2009 at 03:29 PM 0
Share

Ok, thanks. I can't figure out why it wont initiate my scripts

avatar image yadoa · Nov 28, 2012 at 08:57 AM 0
Share

thank you.

avatar image
2

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Changing the Inspector Titlebar icon, and Text? 2 Answers

Setting Scroll View Width GUILayout 1 Answer

How to use intelisence in mono (in order to get all the contents of other script file) 1 Answer

How to import the object from server to unity 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges