Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 jbourrie · May 08, 2011 at 03:46 AM · editoreditor-scriptingassetsimportingassetdatabase

Error using ImportAssetOptions.ForceSynchronousImport

I'm building an editor that modifies and re-saves scripts from within the Unity interface. When the user hits "Save", I want the script to reimport and update the window with the new script contents.

As part of this code, I am using ImportAssetOptions.ForceSynchronousImport. It works great, does exactly what I need it to do... but it also spits a menacing error into the Output window...


Reload Assembly called from managed code directly. This will cause a crash. You should never refresh assets in synchronous mode or enter playmode synchronously from script code. UnityEditor.AssetDatabase:Refresh(ImportAssetOptions) UnitySMEditor:OnGUI() (at Assets/Editor/UnitySMEditor.cs:70) UnityEditor.DockArea:OnGUI()


I haven't seen a crash associated with this, and the error itself seems a little strange. If I'm not supposed to refresh assets synchronously in script, then why does it give me the option to do so? In what places is it safe to use this option, if not in script?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Joshua · May 08, 2011 at 03:55 AM

Right, I remember watching a video from Unite mentioning this, I think its this one. Basically, a guy working at/with Unity Technologies used this successfully in an editor script he wrote . Practically every other situation in which you use it, it will make unity crash. So in unity 3 they wanted to remove this, but the guy giving the presentation I linked to convinced them to keep it in so he could still use it. So instead they just put in a HUGE warning, I see. :p

So I guess that if the way you use it does what you want it to do, and unity doesn't instantly freezes and shuts down, you're using it in one of the few ways you can savely use it. Just be careful ^.^

  • I have no experience with this, by the way, I'm just deducing this from what I remember having seen in a video a while back.. I might be way of. But I think I'm right
Comment
Add comment · Show 4 · 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 jbourrie · May 08, 2011 at 05:56 AM 0
Share

... great, so I am using it correctly but it still splashes a big error on the screen?

That sucks, because the code I'm writing is intended to give to my students (who I don't want to give them code that spits out a big red scary error message).

Is there a way to surpress this error message? If not, I guess I'll just find a different way to get the same effect...

avatar image Joshua · May 08, 2011 at 12:50 PM 0
Share

Not that I know. $$anonymous$$ust be possible though. I'd advice asking a new question 'how to surpres an error message', I'd be interested in the answer as well. :)

avatar image Joshua · May 08, 2011 at 03:53 PM 0
Share

Here we go, I was curious so I looked it up myself. http://answers.unity3d.com/questions/14786/disable-warning-messages I hope you're using C#

avatar image jbourrie · May 08, 2011 at 07:51 PM 0
Share

Thanks: I saw that #pragma, but this error is actually an "Error", not a warning, so it doesn't display a number that can be surpressed (unless that number is just hidden somewhere... couldn't find it with a Google search though).

Being able to force synchronous mode simplifies this task into one line of code, but it looks like I'll probably just need to allow for asynchronous importing.

avatar image
0

Answer by Jerry-Lee · Nov 25, 2016 at 07:58 AM

I think you can use codes to clear console messages like this, because I did it. Type type = Type.GetType("UnityEditorInternal.LogEntries,UnityEditor.dll"); MethodInfo info = type.GetMethod("Clear", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (info != null) info.Invoke(null, parameters);

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

1 Person is following this question.

avatar image

Related Questions

Why Are My Project Assets Constantly Re-Importing? 2 Answers

Load an asset right as it is imported? 0 Answers

ObjectField Get object type(Asset, Scene Object) 2 Answers

Is there a way to get a unique hash for an asset? 1 Answer

How to identify an asset? 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