- Home /
How to make sure editor completed refreshing before running other codes?
I have a Unity editor script that creates another script called TestComponent
"on the fly". So this editor script that I have actually creates TestComponent
as a script and a prefab in the assets folder, and then attempts to add TestComponent
to the prefab. The problem is that script creates TestComponent
using the .net File.WriteAllText
and unity editor needs to refresh the asset database before it could recognise the TestComponent
.
So, I call AssetDatabase.Refresh()
to refresh the assets. However, when I do so, I get the following error:
Script TestComponent has not finished compilation yet. Please wait until compilation of the script has finished and try again.
UnityEngine.GameObject:AddComponent(String)
And I still cannot add the component to the prefab. It seems like the asset refresh is asynchronous and I have to wait for the refresh to complete before I could add the component. Since the lines of the code in my editor script just follows one after another, I get that error.
Then now, how can I make sure that the editor has completed refreshing the assets and is ready to run the other lines that will add the component script to the prefab?
Answer by Heino · Sep 17, 2013 at 12:44 PM
Maybe you use this one: http://docs.unity3d.com/Documentation/ScriptReference/EditorApplication-isCompiling.html
Your answer
Follow this Question
Related Questions
Unity Editor script arrows to display a variable 2 Answers
Mark gameobject field as changed from prefab 2 Answers
Prefab mode doesn't show prefab, still shows old scene. 7 Answers
Unity Editor: Vertical scrollbar in flexible Editor Window 1 Answer
Editor-only circular contour around prefab instances 2 Answers