- Home /
Why does Unity create folder/file only when I re-import the script that triggered it?
Hi!
I have two separate scripts that give me a very similar problem. Both scripts should create something inside the Asset folder (one creates a folder, the other an .xml file). In both cases, the folder/file is not created when I expect it to.
If for example I run this from Start() :
static void CreateFolders()
{
string f = Application.dataPath + "/";
Directory.CreateDirectory(f + "NewFolder");
Debug.Log("Created directories");
}
It prints the Debug.Log immediately just fine. The NewFolder will not be in my Asset folder though. This will only be created, if I go into the script that ran this code, edit it, and save it again..? Unity will then briefly show that it's compiling the scripts. Only then does NewFolder appear inside the Asset folder.
Does anyone know what I'm doing wrong, and what I can do to fix this?
Thanks!
Answer by mrstruijk · Nov 13, 2018 at 07:15 AM
Ok, even though this is still annoying, it apparently only happens inside the Asset folder. When I get the scripts to export it to another folder outside of Unity, the data is exported straight away.
I'll use this workaround for now.