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
11
Question by Ony · Mar 17, 2010 at 01:18 AM · priority

How to set starting order of scripts?

Let's say I have three scripts, each attached to three separate game objects.

In one script I am loading up some data from text files, and that data needs to be available to the other two scripts, as they need use of it in their Start() functions.

Based on the Debug.Log lines I have printed out from each of the scripts, it appears that Unity just sort of arbitrarily loads everything as it feels like it. How can I set the order of script priority so that a certain script ALWAYS loads and finishes before any other scripts in the project do?

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 UnitedBluff · Nov 05, 2015 at 09:11 PM 0
Share

I must say, this is terrible design by unity :( it's not even necessary to explain why

avatar image tanoshimi UnitedBluff · Nov 06, 2015 at 07:03 AM 0
Share

@UnitedBluff This is an (answered) question from 5 years ago that's not even an issue...

http://docs.unity3d.com/$$anonymous$$anual/ExecutionOrder.html

avatar image UnitedBluff tanoshimi · Nov 06, 2015 at 12:50 PM 0
Share

I'm sorry, but I don't understand your point. I know you can "control" execution order by putting some code in Awake and some in Start...but that requires that one script "knows" about other scripts..and you can really only control a very few number of scripts initialization order..what if you have 20 scripts that need to be executed in a specific order ? You only have Awake and Start..you would need "Awake1" "Awake2" etc..(again, horrible design.). Why not simply let the scripts initialize in the order they were added to the GameObject. So yes. it is still an issue, unless there are other ways to fix this.

Show more comments

2 Replies

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

Answer by Eric5h5 · Mar 17, 2010 at 01:31 AM

Use Awake() to initialize stuff that has to be done before Start(). If you need more than two levels of ordering, then you have to implement some kind of routine on a game manager object that calls functions on other scripts in your defined order.

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 Ony · Mar 17, 2010 at 02:17 AM 0
Share

I've been using Awake for this and I had the Debug.Log info printing from WITHIN the functions I was calling with Awake. From that it appeared as is my Awake things were running with everything else. I just put the Debug.Log stuff into the actual Awake function and now I see them print at the beginning, every time.

Thanks for the info and leading me in the right direction.

avatar image
1

Answer by Content1of_akind · Apr 25, 2019 at 05:14 PM

https://docs.unity3d.com/Manual/class-MonoManager.html Edit > Player Settings > Script Execution.

Under (Default Time) click on the Plus(+) Sign on the bottom right to add the Script(GameManager Script) that should run before any other Script. The script name doesn't matter, just the concept of which Script you want to run before another. that being said if the script works do not follow these steps at all, your code is fine as is. Only use it if your script is interfering with time order of another Script from performing properly. Which is usually the GameManager and AudioManager I've only came across.

This is what helped my music to start playing again because my GameManager Script and AudioManager Script was loading(running) at the same or wrong time which I guess caused it not to recognize the AudioManager.instance I wrote to the GameManager. Hope this helps you as it did me, Cheers!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to import the object from server to unity 2 Answers

Setting Scroll View Width GUILayout 1 Answer

Can someone help me fix my Javascript for Flickering Light? 6 Answers

Material doesn't have a color property '_Color' 4 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