Beispiel #1
0
        public static SemanticVersion TryManualParseSavedVersion(string pluginId)
        {
            try
            {
                var oldProjectRootPath     = MigrationUtility_Asset_to_Package.GetLegacyRootPath(pluginId);
                var oldProjectSettingsPath = Path.Combine(oldProjectRootPath, "Generated", "ProjectSettings.asset");

                if (!File.Exists(oldProjectSettingsPath))
                {
                    return(new SemanticVersion());
                }

                string projectSettingsText = System.IO.File.ReadAllText(oldProjectSettingsPath);
                int    savedVersionIndex   = projectSettingsText.IndexOf("savedVersion", StringComparison.Ordinal);
                if (savedVersionIndex == -1)
                {
                    return(new SemanticVersion());
                }

                Match majorVersionMatch = new Regex(@"""major"":([0-9]*),").Match(projectSettingsText, savedVersionIndex);
                Match minorVersionMatch = new Regex(@"""minor"":([0-9]*),").Match(projectSettingsText, savedVersionIndex);
                Match patchVersionMatch = new Regex(@"""patch"":([0-9]*),").Match(projectSettingsText, savedVersionIndex);

                int majorVersion = int.Parse(majorVersionMatch.Groups[1].Value);
                int minorVersion = int.Parse(minorVersionMatch.Groups[1].Value);
                int patchVersion = int.Parse(patchVersionMatch.Groups[1].Value);

                return(new SemanticVersion(majorVersion, minorVersion, patchVersion, null, 0));
            }
            catch (Exception)
            {
                return(new SemanticVersion());
            }
        }
        public override void Run()
        {
            plugin.configuration.Initialize();

            try
            {
                MigrateProjectSettings();
            }
#pragma warning disable 168
            catch (Exception e)
#pragma warning restore 168
            {
                Debug.LogWarning("There was a problem migrating your Visual Scripting project settings. Be sure to check them in Edit -> Project Settings -> Visual Scripting");
#if VISUAL_SCRIPT_DEBUG_MIGRATION
                Debug.LogError(e);
#endif
            }

            try
            {
                MigrationUtility_Asset_to_Package.MigrateEditorPreferences(this.plugin);
            }
#pragma warning disable 168
            catch (Exception e)
#pragma warning restore 168
            {
                Debug.LogWarning("There was a problem migrating your Visual Scripting editor preferences. Be sure to check them in Edit -> Preferences -> Visual Scripting");
#if VISUAL_SCRIPT_DEBUG_MIGRATION
                Debug.LogError(e);
#endif
            }
        }
        public override bool Run(out SemanticVersion savedVersion)
        {
            var manuallyParsedVersion = MigrationUtility_Asset_to_Package.TryManualParseSavedVersion("Bolt.State");

            savedVersion = manuallyParsedVersion;

            return(savedVersion != "0.0.0");
        }
Beispiel #4
0
        private static void CleanupLegacyUserFiles()
        {
            // Todo: This partially fails because we can't delete the loaded sqlite3 dll.
            // Causes no problems for the migration here, but leaves files for the user to delete

            // Remove Old Ludiq folder, including project settings and unit database
            var rootPath             = MigrationUtility_Asset_to_Package.GetLegacyRootPath("Bolt.Core");
            var ludiqFolderFullPath  = Directory.GetParent(rootPath).FullName;
            var ludiqFolderAssetPath = Path.Combine("Assets", PathUtility.FromAssets(ludiqFolderFullPath));

            AssetDatabase.DeleteAsset(ludiqFolderAssetPath);
        }
        private static void MigrateProjectSettings()
        {
            // Bolt.State -> VisualScripting.State
            BoltState.Configuration.LoadOrCreateProjectSettingsAsset();

            var legacyProjectSettingsAsset = MigrationUtility_Asset_to_Package.GetLegacyProjectSettingsAsset("Bolt.State");

            if (legacyProjectSettingsAsset != null)
            {
                BoltState.Configuration.projectSettingsAsset.Merge(legacyProjectSettingsAsset);
            }

            BoltState.Configuration.SaveProjectSettingsAsset(true);
            BoltState.Configuration.ResetProjectSettingsMetadata();
        }
Beispiel #6
0
        private static void RemoveLegacyPackageFiles()
        {
            // Todo: This partially fails because we can't delete the loaded sqlite3 dll.
            // Causes no problems for the migration here, but leaves files for the user to delete

            // Remove Assemblies
            var rootPath            = MigrationUtility_Asset_to_Package.GetLegacyRootPath("Bolt.Core");
            var assembliesFullPath  = $"{Directory.GetParent(rootPath).FullName}/Assemblies";
            var assembliesAssetPath = Path.Combine("Assets", PathUtility.FromAssets(assembliesFullPath));

            // Todo: This currently fails because of the sqlite dll. Deletes everything else
            AssetDatabase.DeleteAsset(assembliesAssetPath);

            // Remove icon map files
            AssetDatabase.DeleteAsset(MigrationUtility_Asset_to_Package.GetLegacyIconMapAssetPath("Bolt.Core"));
            AssetDatabase.DeleteAsset(MigrationUtility_Asset_to_Package.GetLegacyIconMapAssetPath("Bolt.Flow"));
            AssetDatabase.DeleteAsset(MigrationUtility_Asset_to_Package.GetLegacyIconMapAssetPath("Bolt.State"));
        }
Beispiel #7
0
        private static void MigrateProjectSettings()
        {
            // Merging Ludiq.Graphs, Ludiq.Core and Bolt.Core
            var legacyProjectSettingPluginIds = new string[]
            { "Ludiq.Graphs", "Ludiq.Core", "Bolt.Core" };

            BoltCore.Configuration.LoadOrCreateProjectSettingsAsset();

            foreach (var pluginId in legacyProjectSettingPluginIds)
            {
                var legacyProjectSettingsAsset = MigrationUtility_Asset_to_Package.GetLegacyProjectSettingsAsset(pluginId);
                if (legacyProjectSettingsAsset != null)
                {
                    BoltCore.Configuration.projectSettingsAsset.Merge(legacyProjectSettingsAsset);
                }
            }

            BoltCore.Configuration.SaveProjectSettingsAsset(true);
            BoltCore.Configuration.ResetProjectSettingsMetadata();
        }
Beispiel #8
0
        private static void MigrateVariablesAssets()
        {
            // We have application and saved variables to migrate
            var variableAssetNames = new string[] { "ApplicationVariables", "SavedVariables" };

            foreach (var fileName in variableAssetNames)
            {
                var rootPath        = MigrationUtility_Asset_to_Package.GetLegacyRootPath("Bolt.Core");
                var legacyAssetPath = Path.Combine(rootPath, "Generated", "Variables", "Resources", fileName + ".asset");
                var newAssetPath    = Path.Combine(Paths.assets, "Bolt.Generated", "VisualScripting.Core", "Variables", "Resources", fileName + ".asset");
                var directory       = Path.GetDirectoryName(newAssetPath);

                if (File.Exists(legacyAssetPath) && !File.Exists(newAssetPath))
                {
                    if (!Directory.Exists(directory))
                    {
                        Directory.CreateDirectory(directory);
                    }
                    File.Copy(legacyAssetPath, newAssetPath);
                    File.Move(legacyAssetPath + ".meta", newAssetPath + ".meta");
                }
            }
        }
Beispiel #9
0
        public override void Run()
        {
            RemoveLegacyPackageFiles();

            // We need to clear our cached types so that legacy types (Bolt.x, Ludiq.y, etc) aren't held in memory
            // by name. When we deserialize our graphs anew, we need to deserialize them into their new types (with new
            // namespaces) and the cached type lookup will interfere with that. See RuntimeCodebase.TryDeserializeType()
            RuntimeCodebase.ClearCachedTypes();

            RuntimeCodebase.disallowedAssemblies.Add("Bolt.Core.Editor");
            RuntimeCodebase.disallowedAssemblies.Add("Bolt.Core.Runtime");
            RuntimeCodebase.disallowedAssemblies.Add("Bolt.Flow.Editor");
            RuntimeCodebase.disallowedAssemblies.Add("Bolt.Flow.Runtime");
            RuntimeCodebase.disallowedAssemblies.Add("Bolt.State.Editor");
            RuntimeCodebase.disallowedAssemblies.Add("Bolt.State.Runtime");
            RuntimeCodebase.disallowedAssemblies.Add("Ludiq.Core.Editor");
            RuntimeCodebase.disallowedAssemblies.Add("Ludiq.Core.Runtime");
            RuntimeCodebase.disallowedAssemblies.Add("Ludiq.Graphs.Editor");
            RuntimeCodebase.disallowedAssemblies.Add("Ludiq.Graphs.Runtime");

            ScriptReferenceResolver.Run();

            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);

            plugin.configuration.Initialize();

            try
            {
                MigrateProjectSettings();
            }
#pragma warning disable 168
            catch (Exception e)
#pragma warning restore 168
            {
                Debug.LogWarning("There was a problem migrating your Visual Scripting project settings. Be sure to check them in Edit -> Project Settings -> Visual Scripting");
#if VISUAL_SCRIPT_DEBUG_MIGRATION
                Debug.LogError(e);
#endif
            }

            try
            {
                MigrationUtility_Asset_to_Package.MigrateEditorPreferences(this.plugin);
            }
#pragma warning disable 168
            catch (Exception e)
#pragma warning restore 168
            {
                Debug.LogWarning("There was a problem migrating your Visual Scripting editor preferences. Be sure to check them in Edit -> Preferences -> Visual Scripting");
#if VISUAL_SCRIPT_DEBUG_MIGRATION
                Debug.LogError(e);
#endif
            }

            try
            {
                MigrateVariablesAssets();
            }
#pragma warning disable 168
            catch (Exception e)
#pragma warning restore 168
            {
                Debug.LogWarning("There was a problem migrating your Visual Scripting application or saved variables. You might want to restore your backup");
#if VISUAL_SCRIPT_DEBUG_MIGRATION
                Debug.LogError(e);
#endif
            }
        }