public static void GenerateCSharpScript() { var scripts = GenerationUtility.GenerateProjectScripts(true); // var pathScripts = new List<string>(); // Directory.CreateDirectory(GenerationUtility.tempGeneratedFolder); // foreach(var script in scripts) { // var path = Path.GetFullPath(GenerationUtility.tempGeneratedFolder) + Path.DirectorySeparatorChar + "F" + script.GetGenerationID() + ".cs"; // using(StreamWriter sw = new StreamWriter(path)) { // sw.Write(GenerationUtility.ConvertLineEnding(script.ToScript(), false)); // sw.Close(); // } // pathScripts.Add(path); // Debug.Log(File.Exists(path)); // } // EditorUtility.DisplayProgressBar("Compiling Scripts", "", 1); // GenerationUtility.Compile(scripts.Select(s => s.ToScript()).ToArray()); var db = GetDatabase(); EditorUtility.DisplayProgressBar("Saving Scripts", "", 1); var dir = generatedPath + Path.DirectorySeparatorChar + "Scripts"; Directory.CreateDirectory(dir); foreach (var script in scripts) { var path = Path.GetFullPath(dir) + Path.DirectorySeparatorChar + script.fileName + ".cs"; var assetPath = AssetDatabase.GetAssetPath(script.graphOwner); if (File.Exists(assetPath.RemoveLast(6).Add("cs"))) { //Skip when the graph has been compiled manually continue; } using (StreamWriter sw = new StreamWriter(path)) { List <ScriptInformation> informations; var generatedScript = script.ToScript(out informations); if (informations != null) { uNodeEditor.SavedData.RegisterGraphInfos(informations, script.graphOwner, path); } sw.Write(ConvertLineEnding(generatedScript, false)); sw.Close(); } foreach (var root in script.graphs) { if (db.graphDatabases.Any(g => g.graph == root)) { continue; } db.graphDatabases.Add(new uNodeResourceDatabase.RuntimeGraphDatabase() { graph = root, }); EditorUtility.SetDirty(db); } } AssetDatabase.Refresh(); AssetDatabase.SaveAssets(); EditorUtility.ClearProgressBar(); db.ClearCache(); Debug.Log("Successful generating project script, project graphs will run with native c#." + "\nRemember to compiles the graph again if you made a changes to a graphs to keep the script up to date." + "\nRemoving generated scripts will makes the graph to run with reflection again." + "\nGenerated project script can be found on: " + dir); }