Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • 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
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

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 /
  • Help Room /
avatar image
0
Question by Jacooboo · Mar 15, 2017 at 07:56 AM · unity 5errormessage

NullReferenceException: Object reference not set to an instance of an object

I get this error in unity: NullReferenceException: Object reference not set to an instance of an object PlayerSetup.OnDisable () (at Assets/Scripts/PlayerSetup.cs:96)

here is a screenshot of my playersetup script where the error comes from http://imgur.com/a/cA8fc

I don’t know what’s wrong pls help me

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by MeronSoda · Mar 15, 2017 at 03:09 PM

It seems your singleton GameManager has no instance.

1) Did you forget to attach your Component (GameManager) to any object in hierarchy?

2) In you GameManager script, did you assign a value for instance in the Awake function (not in Start function)?

void Awake () { instance = this; }

3) Is the object in hierarchy which holds the GameManager component active?

4) Are there any other scripts in scene that before running require GameManager to be already set up? If yes, consider defining an "Execution Order" in Edit > Project Settings > Script Execution Order.

Comment
Add comment · Show 1 · 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 Jacooboo · Mar 16, 2017 at 08:04 AM 0
Share

$$anonymous$$eronSoda i tried to do my best about what you said but it still doesn't work. Here is screenshots of my Game$$anonymous$$anager. http://imgur.com/a/dg$$anonymous$$a7

Would you like to Collaborate and help me?

avatar image
0

Answer by RecyclingBen · Mar 15, 2017 at 11:32 AM

It seems like you are trying to reference a gameobject (or some other kind of object) that is empty. If you see something in your inspector panel that says something like "empty (gameobject)" then drag over the gameobject/script/sprite/whatever you are trying to reference into it and it should work perfectly.

Comment
Add comment · Show 1 · 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 Jacooboo · Mar 15, 2017 at 02:53 PM 0
Share

Okey, thank you! I'll try it.

avatar image
0

Answer by kpatulrpatel · Jul 30, 2020 at 09:09 AM

==> Create GameObject attach GameManager Script ==> In Awake() Method

  private static GameManager instance;

 public static GameManager Instance
 {
     get
     {
         if (!instance)
         {
             instance = FindObjectOfType(typeof(GameManager )) as GameManager ;

             if (!instance)
             {
                 Debug.LogError("There needs to be one active GameManager script on 
           a GameObject in your scene.");
             }
         }
         return instance;
     }
 }
    Awake()
   {
       instance = this;
       DontDestroyOnLoad(this);
   }

==> Add GameManager in Script Execution Order.

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.

Follow this Question

Answers Answers and Comments

142 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

All the scripts in my project are giving me a CS0103 and CS1061 errors! 1 Answer

public UnityEngine.UI.Text fixing errors. 1 Answer

I keep getting Unity.exe-application error 0xc000007b when I try to open Unity 5 or above ? Help! 4 Answers

Cannot perform upm operation: Cannot read property 'map' of undefined [NotFound].See console for more details 4 Answers

this is my pause menu script but it doesn't pause my game or neither the pause menu disappear however restart works fine 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges