• 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
Question by yoziva · Mar 05, 2017 at 03:27 PM · reloadingcompilationonenablescript execution order

OnEnable - Script Hot Reload - Script Execution Order

Hi,

I have a script A with an execution order set to -500.

I have a script B with no script execution order set (default time)

The order of the OnEnable calls are the following when pressing play (it's fine):

  • A OnEnable

  • B OnEnable

I'm changing some code while playing. Once Unity has finished recompiling, the following calls are done:

  • B OnEnable

  • A OnEnable

I would have expected the follwing order (same has the initial order):

  • A OnEnable

  • B OnEnable

My goal is to have the script B listen to an event of A, and make sure the event is still register after the script recompilation:

 public class B : MonoBehaviour
 {
     protected void OnEnable()
     {
         Debug.Log("B OnEnable ");
         A.Instance.MyEvent.AddListener(OnAEvent);
     }
 }

I'm using Unity 5.5.0f3

Thanks!

Comment

People who like this

0 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 Kastenfrosch2 · May 20, 2018 at 01:49 PM 0
Share

Having the same problem in 2017.3.1f1 :(

avatar image Harinezumi · May 22, 2018 at 11:45 AM 0
Share

It has been a long while since I trusted hot reloading: it just always messed up and gave me errors. I'm surprised it works for others, but I'd recommend not to rely on it too much.

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by hexagonius · May 20, 2018 at 03:05 PM

I recommend you to report that as a bug. nothing from the documentation says anything about this anomaly when hot loading.

Comment

People who like this

0 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 Kastenfrosch2 · May 20, 2018 at 06:41 PM 0
Share

Thanks for confirming, that it's not stated in the documentation. I sent a Bug Report ( https://fogbugz.unity3d.com/default.asp?1040132_rpv91mrd90ans55h ) and later noticed that there was already one pending ( https://issuetracker.unity3d.com/issues/scriptexecutionorder-ignored-when-reloading-scripts-during-playmode )

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Muzzle flash stop when reloading? 3 Answers

Reloading current scene make game laggy? 0 Answers

When I reload my Scene, nothing works. I think it's because of a dontDestroyOnLoad gameObject 0 Answers

How does Unity compilation work? 1 Answer

How does Unity call Update() etc without override or reflection? 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