- Home /
How can I make a text file immediately appear in my project from an AssetPostProcessor script?
When I right click in the project and add a new text file (e.g. c# script) it appears immediately. Likewise, if I create a new text file in an external text editor, it appears immediately in my Unity project view.
However, if I use StreamWriter in an AssetPostProcessor script to create a text file, it does not appear in my project unless I either:
- reimport the new script's parent folder or
- add or save a text file through one of the other (previously mentioned) means
Right now I am working around this by using AssetDatabase.CreateAsset() to create a material with a .cs extension and then using StreamWriter to overwrite it, but its contents still don't refresh unless I do (1) or (2) above. Is there a better or different way to handle this?
Answer by duck · Apr 14, 2010 at 04:36 PM
Have you tried using AssetDatabase.ImportAsset to force an import/update after creating the file?
Your answer
Follow this Question
Related Questions
Creating a prefab in AssetPostprocessor.OnPostprocessAllAssets(). 1 Answer
Creating an texture asset in editor script 2 Answers
How to access ScriptableObject during initial import pre-process? 0 Answers
Why won't this (very simple) editor script compile? CS1041 1 Answer
How can I change the default max size of a texture from an editor script (in import settings)? 1 Answer