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 Damenz · Jul 26, 2016 at 09:59 PM · error messagescene-loadingstart

Cant find component after scene load but it exists ! HELP!

Hi there, i am facing a huge problem.

I am trying to push scripts reference into a list of the script type on start.

I am using a global Singleton which call the start of all other objects in my prefered order.

After loading the scene from the menu, i am trying to push some gameobject scripts but it gives me "Object reference not set to an instance of an object" when the script & object do exist.

Why do i know he exist?

Just before adding the script to the list, i did a Debug.log of one of the script property and it does return the property correctly. But when i add it to the list, it says the error i just said.

This is very weird and very frustrating. Anyone has a solution?

     void Start()
     {
         Debug.Log("Game start");
         Transform tr = GameObject.Find("_SceneObjects").transform.FindChild("Cubes");
 
         for (int i = 0; i < 8; i++)
         {
             Debug.Log(tr.GetChild(i).GetChild(0).gameObject.GetComponent<FlipBehaviour>().m_order); //WORKS
             m_cubes.Add(tr.GetChild(i).GetChild(0).gameObject.GetComponent<FlipBehaviour>());//OBJECT REFERENCE NOT SET TO AN INSTANCE OF AN OBJECT
         }
 
         //-------------- START------------------
         ClassicModeManager.Instance._Start();
         ResourcesManager.Instance._Start();
         UIManager.Instance._Start();
 
         foreach (FlipBehaviour cube in m_cubes)
         {
             cube._Start();
         }
 
         ClassicModeManager.Instance.NextLevel();
 
 
         Debug.Log("Ranking : " + ResourcesManager.Instance.Sprites.BronzeRanking.name);
     }

EDIT: Im gonna leave this here in case my solution can help others.

For a reason i dont know (but which makes sense), you have to use the "new" key for the List when you load the scene from another scene.

If you test the loaded scene directly, you dont need the "new" key. You can simply create a new list like this:

List list;

but if you load the scene, you have to create a new instance of the list

List list = new List();

and now it works.

I was right, the script was found and exist, but the list is equal to null. So the "Object reference = null" error was for the list and not the component itself.

Answered my own question ahah !

Hope it will help others

Damenz

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

0 Replies

· Add your reply
  • Sort: 

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

63 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

Related Questions

compiler Not able to load lighting on resetting scene 2 Answers

Start function not called after reloading scene 0 Answers

I am in a bind with these compiler errors. First time user/script 1 Answer

How can I get around this error? 0 Answers

I get this error CS1031: Type expected pls help!! 0 Answers


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