Beispiel #1
0
        internal static IEnumerable <ResourceDirectory> GetResourcePaths()
        {
            foreach (string resourcePath in _resourcePaths)
            {
                string enabledPath  = Path.Combine(SRInternalEditorUtil.GetRootPath(), resourcePath);
                string disabledPath = Path.Combine(SRInternalEditorUtil.GetRootPath(), resourcePath) + DisabledDirectoryPostfix;

                yield return(new ResourceDirectory(enabledPath, disabledPath));
            }
        }
Beispiel #2
0
        public static void RunMigration(Migration migration)
        {
            if (EnableLog)
            {
                Debug.Log("Running Migration: " + migration.Id);
            }

            var assetPaths = AssetDatabase.GetAllAssetPaths();
            var root       = new DirectoryInfo(SRInternalEditorUtil.GetRootPath());

            if (EnableLog)
            {
                Debug.Log("Using Root Path: " + root.FullName);
            }

            var obsoleteAssets = migration.ObsoleteFiles.Select(p => root + "/" + p).ToList();
            var deleteQueue    = assetPaths.Where(assetPath => obsoleteAssets.Contains(assetPath)).ToList();

            if (deleteQueue.Count == 0)
            {
                return;
            }

            var message = "The following files used by a previous version of SRDebugger are obsolete and can be safely deleted: \n\n" +
                          deleteQueue.Aggregate((s1, s2) => s1 + "\n" + s2);

            Debug.Log(message);

            message += "\n\nIt is recommended to delete these files.";

            if (EditorUtility.DisplayDialog("SRDebugger Migration Assistant",
                                            message, "Delete Now", "Ignore"))
            {
                foreach (var s in deleteQueue)
                {
                    Debug.Log("[SRDebugger] Deleting Asset {0}".Fmt(s));

                    if (!AssetDatabase.DeleteAsset(s))
                    {
                        Debug.LogWarning("[SRDebugger] Error deleting asset {0}".Fmt(s));
                    }
                }

                Debug.Log("[SRDebugger] Migration Complete");
            }
            else
            {
                EditorUtility.DisplayDialog("SRDebugger Migration Assitant",
                                            "You can run this migration check again via the \"Run Migrations\" button in the advanced tab of the SRDebugger settings window.", "OK");
            }
        }
Beispiel #3
0
        static void SetResourcesEnabled(bool enable)
        {
            AssetDatabase.StartAssetEditing();

            foreach (ResourceDirectory d in GetResourcePaths())
            {
                d.SetDirectoryEnabled(enable);
            }

            AssetDatabase.StopAssetEditing();

            AssetDatabase.Refresh();

            AssetDatabase.ImportAsset(SRInternalEditorUtil.GetRootPath(
                                          ), ImportAssetOptions.ImportRecursive | ImportAssetOptions.ForceUpdate);
        }