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 Minsc · Jun 29, 2015 at 09:15 PM · raycastparallel

workaround for parallelizing function calls from Unity API?

Hi there,

I am doing a visual recognition system, and to do more advanced stuff I need to use a lot of raycasts, however that won't do it in term of performance if they have to be done sequentially. On the other hand, it looks like it is not possible to parallelize function calls from the Unity API, is it really completely the case or can I do some kind of configuration to allow that?

Thank you in advance for your help,

Minsc

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

Answer by Dave-Carlile · Jun 29, 2015 at 09:15 PM

If you need actual parallelism you can use threading, but all access to the Unity API must happen on the main thread.

Another common technique for heavy workloads is to spread the work across multiple frames - Coroutines are good for doing this. If you're not doing a lot of raycasts all the time this may be a viable option.

Comment
Add comment · Show 6 · 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 Minsc · Jun 30, 2015 at 01:35 AM 0
Share

Cool thanks so it is actually possible to parallelize Unity API functions, I will look into the threading option I need to do a lot of raycasts, it is for a pointcloud detection.

avatar image Dave-Carlile · Jun 30, 2015 at 01:38 AM 0
Share

I may not have been clear - Unity API functions $$anonymous$$UST be executed on the main thread, meaning you can't execute them in your own threads.

avatar image samizzo · Jun 30, 2015 at 02:36 AM 0
Share

Yeah, if you wanted to multithread it, you'd have to implement everything yourself.

avatar image Minsc · Jun 30, 2015 at 05:23 AM 0
Share

Um okay indeed, I will look into alternatives or maybe implement my own raycast system. But it is only Unity API that is not parallelizable right? If I use another API in my code can I still multithread it?

avatar image tanoshimi · Jun 30, 2015 at 06:18 AM 0
Share

Yep - if you want to do your image recognition stuff in a separate thread, that's fine, but the initial raycast(s) must be from the main thread.

Show more comments

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

[SOLVED] How to set an object's rotation parallel to a wall. 1 Answer

How to raycast on multi core ECS 0 Answers

raycast help need 2 Answers

Push object in direction of camera 0 Answers

Raycast not colliding with selected layer 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