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 /
avatar image
0
Question by Sosin · Dec 27, 2016 at 10:39 AM · errorscenesscene loadmissingreferenceexceptionscene change

MissingReferenceException after loading scene.

I'm making a game with DarkRift API, first the player has to create the server, then the host needs to wait for other players in a lobby before starting the game. When a player connects to a server, the active scene for that player changes with SceneManager.LoadScene(1, LoadSceneMode.Single) (I also tried adding SceneManager.SetActiveScene(SceneManager.GetSceneByBuildIndex(1)) after that line).

Here's the problem, if a player leaves the server, the scene of that player changes to the first one ( SceneManager.LoadScene(1, LoadSceneMode.Single) ), but if he tries to join again to a server, in the moment when he receives all the DarkRiftAPI messages to sync all the stuff, the script needs to change the texts with the info, but it says that the Text has been destroyed.

I putted a Debug.Log of the Texts, and in the moment when all the messages are received, the Texts are null, but after the player stops receiving, the Texts are normal.

Basically, the first time a player joins a server, everything is normal, but if he disconnects and try to connect to other server, that happens.

I tried to change the Script Execution Order but it doesn't fixed it.

EDIT: I believed when I load the scene again, the variables are the same before the scene unloaded, so in the first call the variables aren't the new Objects, but if I put a Debug.Log on Start, the object exists, but on any other void, the object is null.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Sosin · Dec 27, 2016 at 11:14 PM

I think i found the problem (very dumb).

Every Update on the menu, I was testing if the player was connected to a server, if it was, change the scene. But because I was testing it every Update, for some reason the test ( DarkRiftAPI.isConnected ) executed twice, making the scene to load two times.

EDIT: Nope, it wasn't the problem, still the same, I believed when I load the scene again, the variables are the same before the scene unloaded, so in the first call the variables aren't the new Objects, but if I put a Debug.Log on Start, the object exists, but on any other void, the object is null.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

MissingReferenceException after loading a scene, missing object of type text and button. 0 Answers

GameManager trying to access method from deleted GameManager via the InvokeRepeating() function 0 Answers

How to play Animation of a button first, THEN only proceeding to the next scene ? 3 Answers

Strange Errors when building game 0 Answers

Destroyed Object Error 2 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