Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Locomalito · Nov 28, 2014 at 07:05 AM · orderexecution

To use or not to use script execution order

I'm just wondering if this feature is widely used by the pro devs. I mean, is this really what we should use to make sure a script is executed first before the other or should I just make function calls/init functions then call then manually when certain conditions are met.

I have this object pooling class. And I have to make sure that all the objects are created first before I get something on the pool. It returns an error(bec some of my script runs first before this object pool class) unless I use this Script Execution order thing. In as3 we have this document class where you control the order of the class to be executed. Is this feature the equivalent of that in unity, what about in C#(outside unity) where I'm not sure if this feature is available how would you normally control code execution order?

I'll also appreciate suggestions for a more robust way of script execution order.

Comment
Add comment · Show 4
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 meat5000 ♦ · Nov 28, 2014 at 12:09 PM 0
Share

It seems to me that Execution Order matters most when you are pushing floating value changes to scripts at the wrong time. (They are floating as you are unsure whether the change has been made on the current script execution).

It seems far more reliable to retrieve values from a script ins$$anonymous$$d. It appears to cut out most need for Execution Order.

The root-causes not dealt with by the above are usually avoided with the odd yield here and there.

avatar image NaRango4 · Nov 28, 2014 at 01:26 PM 0
Share

I would use 'script execution order' as my last resource. It doesn't make sense if you use it for quick-hacks.

avatar image RudyTheDev · Nov 28, 2014 at 01:51 PM 0
Share

Outside Unity, Awake() and Start() don't get called, because outside Unity $$anonymous$$onoBehaviour is not defined. So script execution order is purely a Unity thing. It's the answer to a traditional game loop when you need specific script run order but haven't connected them together yourself.

This is useful when writing plugins and modular code, as you don't/can't know how specific game does its logic. But you still want a proper execution order.

Of course, the more I work with it, the less I like it. Once your game goes past a certain complexity, execution order becomes another hack. (Also, yield and co-routines in never an answer, in my opinion.)

avatar image Xitech_ · Nov 28, 2014 at 02:45 PM 0
Share

I've had a simulair question. Just use it. If pro's use it or not as long as it works. It wont affect peformance aswell so you should really be bothered

1 Reply

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

Answer by GameVortex · Nov 28, 2014 at 11:57 AM

If it solves your problem then use it, but in almost all cases it can be solved better by smart use of the Awake and Start functions. If that is not possible then using a manager to initialize the objects in the correct order works as well.

In your situation you should probably create all the objects in the pooling manager Awake function and not use it until the Start function of any the object that wants to use the pooling manager.

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 Locomalito · Dec 02, 2014 at 03:40 AM 0
Share

thanks for all the input guys. I'll try to make a smart use of the awake and Start first. then ill use this feature if laziness takes over. but this feature really seems incredibly useful!

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

Script Execution Order library 1 Answer

Order of Update(), Awake(), etc of gameobjects and their child gameobjects 1 Answer

Script Execution Order removes scripts on apply 1 Answer

Manage the script execution order, how? 1 Answer

Two monobehaviour scripts attach to one gameobject and the Update order predicable? 3 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