Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 OperationT · Apr 14, 2016 at 06:48 AM · unity 5threadsthreadingorder-of-executionflow

Program-Flow Control and Unity 5 Engine Threads

Does Unity 5 still use a single thread for the majority of its inner-workings? From here, Unity staff, Aras states that multi-threading is limited to mesh skinning, audio, network, and some other small things, but that was in Nov 2010 (Unity 3?). Does my following program-flow control impede itself from benefiting from multi-threaded performance, if it exists?:

I have been controlling the flow of my game program manually by having a "level" script (a MonoBehaviour) that conceptually sits on top of all other scripts in that game level, and in its Update(), manually calls methods of the other scripts (not MonoBehaviours) in the order that I want. E.g., first script detects user touches and stores them, second script filters user touches to those coinciding with enemy colliders, third script evaluates touch speed to determine which enemy response to trigger, etc.

I don't want to rely Unity's Script Execution Order, which requires me to rely heavily on MonoBehavior, as I'm trying to learn to better architect my code, have looser class coupling, highest unit testability, etc.

Comment
Add comment
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

1 Reply

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

Answer by Bunny83 · Apr 15, 2016 at 04:35 AM

Nothing has changed in this regard. The Unity engine itself does use threads for various tasks internally. However the whole scripting environment is executed from the main thread (aka the main loop). The whole scripting API is designed for a single thread. This design simplifies the API drastically. A Unity game is always frame based. So you always have a destinct order of events happening between two frames (one iteration through the main loop).

Linear code can't possible make itself "multithreaded". If you use multithreading you have to handle that yourself. If you do, you have to create worker threads yourself and do proper synchronising / locking. However keep in mind that the Unity API can't be used from a different thread than the main thread. They actually implemented a check which will throw an exception if you try.

Your vague code descriptions doesn't sound like something that could be split in a meaningful way since every piece of code seems to depend on another (== linear code). There is no way to automatically split code into multiple threads.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How do I call a function in a different CPU core? 2 Answers

Best Practice for Multithreading Procedural Terrain Generation? 1 Answer

How to periodically pull output from an IJobParrallel or is there a better way to do this? 1 Answer

Run return method on new thread? 2 Answers

Using admob rewarded ad in unity singleton pattern 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