• 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 David 3 · Jan 17, 2011 at 11:36 AM ·

Find can only be called from the main thread

Just upgraded to unity 3.1 from 2.6

what does this exception mean?

ArgumentException: Find can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. myclass..ctor ()

however the class does not have a ctor (other than the default).

I am working in c#

the code still works perfectly so i'm a little confused if i need to worry about this or not?

Davud

Comment
Add comment · Show 1
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 zharramadar · Jan 17, 2011 at 03:54 PM 0
Share

No multithreading for you!!! =( Yeah, unfortunately, Unity does not support multithreading (Thread, Backgroundworker, etc) for most of its objects, if not all. I suggest you do all your stuff in another thread but then assign data to Unity objects back in the main thread.

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by jonas-echterhoff · Jan 17, 2011 at 12:10 PM

This means that you are calling Find() from a thread other then the main thread. All UnityEngine functions will only work when called from the main thread. You should worry about this, as it means your code will probably not function as designed.

Comment
Add comment · Show 3 · 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 TokyoDan · Jun 07, 2013 at 06:32 AM 0
Share

How can you tell what is and what isn't the 'main thread'? And how can I avoid calling functions from a thread that isn't the main thread (How do I distinguish that this routine is not part of the 'main' thread)?

avatar image $$anonymous$$ · Apr 22, 2014 at 06:48 PM 0
Share

anyone plan on actually telling us wth the main thread is?

avatar image ritesh_khokhani $$anonymous$$ · Aug 10, 2016 at 01:07 PM 1
Share

main thread is what on which all mono working on, from which unity gets data and returns data..same like main() function in .net c#, java and c++

avatar image
3

Answer by qtownMWD · Aug 02, 2014 at 01:44 AM

this error can be resolved by not asking Unity to something before it has not finished doing something else. for instance, don't start a database query and try to start instantiating prefabs in the middle of the query. store the data from the query in an array. after the data has been downloaded loop thru the array and instantiate the prefabs.

the main thread seems to be at the start() or update() level.

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 ransomec · Apr 18, 2016 at 04:54 PM 0
Share

This answer helped me. I didn't like that Invoke and InvokeRepeating didn't run while Unity's timer was paused, so I made my own Timeout functions that ignored Unity's timer. Bad idea. Unity was (sensibly) not cool with me executing functions outside of its update loop, and one of my rogue functions must have hit the Find() function at some point in execution. Because I strayed from Unity's Init -> Update -> Draw cycle, it yelled at me.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

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

How to check if an object is colliding with another from another script ? 1 Answer

Trying to view paper object on button press GUI Texture 3 Answers

receiving OSC (network) data through unityOSC 2 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