public static void Build(bool initialBuild = false) { if (IsUnitOptionsBuilt()) { return; } if (initialBuild) { ProgressUtility.SetTitleOverride("Visual Scripting: Initial Node Generation..."); } const string progressTitle = "Visual Scripting: Building node database..."; lock (@lock) { using (ProfilingUtility.SampleBlock("Update Node Database")) { using (NativeUtility.Module("sqlite3.dll")) { SQLiteConnection database = null; try { ProgressUtility.DisplayProgressBar(progressTitle, "Creating database...", 0); PathUtility.CreateParentDirectoryIfNeeded(BoltFlow.Paths.unitOptions); database = new SQLiteConnection(BoltFlow.Paths.unitOptions); database.CreateTable <UnitOptionRow>(); ProgressUtility.DisplayProgressBar(progressTitle, "Updating codebase...", 0); UpdateCodebase(); ProgressUtility.DisplayProgressBar(progressTitle, "Updating type mappings...", 0); UpdateTypeMappings(); ProgressUtility.DisplayProgressBar(progressTitle, "Converting codebase to node options...", 0); options = new HashSet <IUnitOption>(GetStaticOptions()); var rows = new HashSet <UnitOptionRow>(); var progress = 0; var lastShownProgress = 0f; foreach (var option in options) { try { var shownProgress = (float)progress / options.Count; if (shownProgress > lastShownProgress + 0.01f) { ProgressUtility.DisplayProgressBar(progressTitle, "Converting codebase to node options...", shownProgress); lastShownProgress = shownProgress; } rows.Add(option.Serialize()); } catch (Exception ex) { Debug.LogError($"Failed to save option '{option.GetType()}'.\n{ex}"); } progress++; } ProgressUtility.DisplayProgressBar(progressTitle, "Writing to database...", 1); try { database.CreateTable <UnitOptionRow>(); database.InsertAll(rows); } catch (Exception ex) { Debug.LogError($"Failed to write options to database.\n{ex}"); } } finally { database?.Close(); ProgressUtility.ClearProgressBar(); ProgressUtility.ClearTitleOverride(); AssetDatabase.Refresh(); //ConsoleProfiler.Dump(); } } } } }