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
3
Question by Pete · Oct 25, 2010 at 04:07 AM · iphoneexceptionproargumentexceptionget-value

ArgumentException: get_value can only be called from the main thread

Hi,

I have just converted a project from Unity iPhone 1.7 to Unity 3 Pro. I am getting this exception when I run the game:

ArgumentException: get_value 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. TankMovement..ctor () PlayerMovement..ctor ()

Double clicking the error message doesn't take me anywhere in the code. It looks like the error is complaining about a constructor, but I haven't specified any in those classes, and there aren't any other parent classes other than MonoBehaviour. I also went so far as to comment out my Start methods, and all the contents of any setXxxx methods from those classes, but nothing changed.

I know this is a pretty open ended question, so sorry for that, but does anyone have any insight into what this error really means, and where the problem is likely to be situated (certain kind of functions for example)?

The above mentioned classes are both C#, as are most my code.

Many thanks,

Pete.

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

3 Replies

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

Answer by Mike 3 · Oct 25, 2010 at 06:27 AM

My bet is it's referring to you assigning to a member variable - the code there will be run at constructor time

e.g.

public class Whatever
{
    private bool myBool = AnotherClass.value;  //throws your error
}

It sounds like you need to look for use of the value property from the compiler warning

Either way - stay clear of calling properties, functions or creating new objects with member variables in monobehaviours, you'll get weird runtime errors (and possibly editor errors)

Comment
Add comment · Show 2 · 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 Pete · Oct 25, 2010 at 07:00 AM 0
Share

$$anonymous$$ike you are spot on. I was doing "protected float soundDelay = Random.value * 10;" so I put that into the Start method and that solved it. Thanks a lot!

avatar image Jean-Fabre · Jun 16, 2012 at 08:36 PM 1
Share

Thanks, It helped me too getting to the bottom of this problem. I was doing something similar in constructors.

avatar image
-1

Answer by ouyangnengjun · Apr 27, 2013 at 12:49 AM

不懂英文真悲剧!我是主摄像机的一个脚本上的Start方法里面调用socket获取起基本数据,数据是全部正常获取了!不过获取之后就报这个错误了!

Comment
Add comment · Show 2 · 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 Chronos-L · Apr 27, 2013 at 01:05 AM 0
Share

這問題在兩年前已經被解答了,所以現在應該不再會有任何活動,也不太可能會有人回覆你的問題。

而且在這,無論你的母語是華語、西班牙語、日語、俄羅斯語等等,大家溝通時都使用英文。

而且,你有求於人,你可不能要求別人來看懂你在說些什麼。

請你盡量使用英語,你也可以使用翻譯工具和我們溝通,我們應該會看得懂。

avatar image Chronos-L · Apr 27, 2013 at 01:11 AM 1
Share

A translation of the conversation:

ouyangnengjun

It is a pity that I can't speak in English. I have script on my main camera, I use a socket to grab the data in Start(), and I got the data without any problem. However, after that, I get the same error.


me

The question is answered 2 years ago, so there should be no activity here anymore, and it is quite unlikely that anyone will reply to your question.

Furthermore, in UA, regardless of your mother tongue: Chinese, Spanish, Japanese, Russian etc, everyone here uses English when they communicate with each other.

And you are the one with the question, you can't expect people to put in extra effort to figure out what you are talking about, you have to make it understandable for them.

Please try to using English, you can use translation tool when you communicate with us, we should be able to figure out the meaning of your sentences.

avatar image
0

Answer by ouyangnengjun · Apr 27, 2013 at 12:51 AM

我也遇到类似问题!有人可以帮忙吗?

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

2 People are following this question.

avatar image avatar image

Related Questions

System.ArgumentException: FindObjectsOfType can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. 0 Answers

Unity iOS Graphics are bad 1 Answer

App Crash IE8 - UnityScriptCompiler 1 Answer

What's the proper way to see if a Vector3 List index is null? 1 Answer

Unity profiler usually fails to connect to iPhone 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