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 gerudoking · Jun 24, 2018 at 04:40 PM · editorexecutableexceptions

Lots of Exceptions on Executable but none in Editor

Hello,

I'm having a problem here and I'm truly clueless about how to solve it. My game runs just fine, no exceptions, when I hit the play button in the editor. However, once I run it's executable the game throws a great amount of exceptions. Most of them are NullReferenceExceptions.

I tried to clean the project in Visual Studio, compile it again, replaced some ProjectSetting files for new ones of new projects, but still I can't figure why so many exceptions are being throw.

Is there any difference between the build and the editor version of a project? What are the common causes to this?

Thanks in advance. Any kind of help is welcome!

Comment
Add comment · Show 2
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 hexagonius · Jun 24, 2018 at 07:07 PM 0
Share

from my experience changed execution orders could be the cause. for example two scripts doing something in their Start methods where one relies on the other to execute first, it's possible, since Start calls are arbitrarily ordered, that they switch places.
second, a lot of errors are usually just happening because some init did not run properly and the errors are thrown from Updates.
Check what's Null and see when and where that's initialized

avatar image Bunny83 · Jun 24, 2018 at 07:21 PM 0
Share

$$anonymous$$anaged exceptions always comes with a stacktrace. So you know the exact method and line number where it happens. Checking this line to figuring out what might be the cause for the null reference is part of a process we call debugging. However we can't debug your problems because:

  • we don't have your code or project

  • we don't know your stacktrace


Note that when you're debugging focus on the first error. Any subsequent errors might be a result of the first one. If an initialization procedure is aborted by an exception, everything that should have been initialized after the point where the error occured is not executed. This may affect countless of see$$anonymous$$gly unrelated errors.


If you want any further help on your issue you have to include more information on your problem


Since this is not a question about Unity but a help request with a debugging problem i will move this question into the help room.

1 Reply

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

Answer by tormentoarmagedoom · Jun 26, 2018 at 10:22 AM

Good day.

I had some similar issue some time ago (other Unity version but maybe is still the same)

The order of execution of all Awake methods was different in editor than in Build executable. The same with all On Enable, and Starts. (for example the Start method of ScriptA was executed before Start of ScriptB, but in Build, the Start of scriptB was executed before Start of scriptA)

So when some script gives information to another script, some objects was execturing it Start method before other object Start, causing some variables was not yet defined and giving the error.

I solved it making a clear order of definition of variables and assigning values using correctly Awake Onenable and Start.

What you can be sure is that all Awakes will be before all others methods, then all OnEnable, and then all Start. And finally the Updates.

Unity have also a way to configure what scripts will be executed before/after what other scripts, so you can configure it at your own.


Edit > Project Settings > Script Execution Order


Bye!

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 gerudoking · Jun 30, 2018 at 01:07 AM 0
Share

That was exactly the problem. Thanks!

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

116 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

Related Questions

Low fps in scene editor and game view 1 Answer

Editor problem, strange colors and scribbles in new projects. Bug? 1 Answer

AudioListener.enabled works is editor, but not on IOS 1 Answer

No C# script working from default load. "Loaded Assembly" 0 Answers

How to Undo a bool on an EditorWindow 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