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 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
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 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
0

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

Thanks for confir$$anonymous$$g, 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.

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

.Js Particle issue (probably easy for moderate coders) 0 Answers

How do reload a video from URL at runtime 0 Answers

Notification of shader recompilation ? 2 Answers

New scripts not found when building in batch mode 2 Answers

How to build a plugin before the compilation of scripts? 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