Is there a better way to create a script in the editor. I tried this but got a error if(Button...) { System.IO.file.create(Application.datapath + "FileName.js"); } Error Sharing violation on path "C/....../.../..." Please help Thanks
you'll want to use just "Assets/" + "FileName.js" The current directory defaults to the folder containing assets and library. Once your done writing all your scripts call AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate) Be warned though, if theres a error in your generated script its hard to back out of it. Like if you have a member in another script using the script's class name and some generation error occurs you'll have to fix errors manually because you cannot just delete it. So if you cannot compile and you make a fix in your generator it wont matter because unity will not compile until there are no errors. Though you may be able to get past it if your Editor directory is in the standard assets or plugins folder.