• 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 fraghalt · Jun 27, 2015 at 11:27 PM · exception

Application.LoadLevel ArgumentException

Hi, I am loading a level from a scene in my main menue with

 Application.LoadLevel(name);

When the new scene is loaded, I get:

  ArgumentException: GetLocalizedString 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. TreeEditor.TreeGroupRoot..cctor () Rethrow as TypeInitializationException: An exception was thrown by the type initializer for TreeEditor.TreeGroupRoot

  ArgumentException: GetLocalizedString 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. TreeEditor.TreeGroupLeaf..cctor () Rethrow as TypeInitializationException: An exception was thrown by the type initializer for TreeEditor.TreeGroupLeaf

It's hard to find out what causes the exception. The scene loads and works but I want to find the Exception. Other scenes which I load don't show the exception.

Non of myscripts call the GetLoalizedString and the scene is so big, i can't remove all the objects to find the cause.

I also bound the event Application.logMessageReceived and the CallStack leads my to the TreeGroupRoot class from Unity with a path to theier buildserver.

Any ideas?

Kind regards

Matthias

Comment
Add comment · Show 3
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 Baste · Jun 28, 2015 at 12:12 AM 0
Share

You're probably calling Application.LoadLevel from a thread that's not supposed to be calling it. There are some methods that are only available if called in the right context - the easiest way to see that is to call a Gizmos method outside of OnDrawGizmos.

What method are you calling it in? That's probably the problem - if you're in an OnGUI or Update or whatever call, you should be fine.

avatar image JennyHide · Jul 22, 2015 at 02:04 PM 1
Share

I got this exception when I opened an older project in Unity 5. I only got it in scenes with trees added to the terrain. Replacing the trees with those in Unity's Environment asset fixed the issue.

avatar image huxley JennyHide · Oct 05, 2015 at 10:27 PM 0
Share

same here. Upgraded to Unity 5.2 and started getting this on any scene with trees painted on the terrain object. Removed all trees and the scene loads fine now.

8 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by fraghalt · Jun 28, 2015 at 01:07 PM

The problem is really strange: The terran contains 5 Splat alphas which caused the problem. When I use another terrain (other terrain data) then the problem is gone. Weird.

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
avatar image
1

Answer by Seifer-Cleric · Nov 06, 2015 at 02:29 PM

For me the problem started after I updated to Unity5. After some trail and error it made sense that prefabs are the problem.

SOLUTION: I created a prefab prefTemp and placed all gameobjects in the scene inside it and deleted it from the scene. Added prefTemp to my scene again and the errors were gone.

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 jordia · Jan 03, 2016 at 03:20 AM 0
Share

well,it works the first time,then breaks again.

avatar image
0

Answer by FlyAnvil · Jan 11, 2016 at 03:28 PM

Try to "edit" the terrain trees, and just reassign the existing tree (in my case at least)

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
avatar image
0

Answer by dreamstate · Jan 18, 2016 at 05:45 PM

Another apparent solution (though sloppy)

Put 1 tree in your first scene.

The error only happens when you load from a scene with no trees to a scene with trees ...well at least for me that is the case and this is the fix....for now :(

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 mar10 · Jun 07, 2016 at 07:52 AM 0
Share

thanks a lot dreamstate, it worked really well for me. quick & dirty solutions are sometimes the most practical. especially in this day & age of rapid development. smart thinking.

avatar image
0

Answer by kamicazer7 · Jan 26, 2016 at 12:26 PM

I have noticed this error once I started using Scenemanager.Loadscene( and recently renamed the level I was loading. Whenever I loaded it, that same error message would show. In this scene. There used to be unity trees in the scene, I later replaced unity tree with my self modeled trees. However the trees remained in the project assets.

The solution that worked for me was to delete all Unity trees from the project assets and save the scene.

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
  • 1
  • 2
  • ›

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

15 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Quit Menu errors 2 Answers

Custom functions in SQLite and Unity 1 Answer

Why is the Object reference is empty ? 1 Answer

Does Resources.Load not fail on purpose? 0 Answers

Is there a way to know that Unity is quiting Play mode? 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