Ejemplo n.º 1
0
        private static void DeferredUpdate()
        {
            EditorApplication.update -= DeferredUpdate;

            if (ModuleManager.CURRENT_MANIFEST == null)
            {
                return;
            }
            ModuleManifest manifest    = ModuleManager.CURRENT_MANIFEST;
            AssetModule    assetModule = ModuleManager.PROJECT_ASSET_MODULES[manifest.module.moduleID];

            if (!ModuleManager.DependenciesResolved(manifest.module))
            {
                EditorUtility.DisplayDialog(MSG_UPDATE_DEPS_TITLE, MSG_UPDATE_DEPS_INFO, "Ok");
                return;
            }

            if (assetModule.module.includesData)
            {
                bool accept = EditorUtility.DisplayDialog(MSG_UPDATE_DATA_TITLE, MSG_UPDATE_DATA_INFO, "Yes", "Cancel");
                if (!accept)
                {
                    return;
                }
            }

            ModuleManager.DeleteModuleContent(manifest.module, false);
            ModuleManager.ImportModuleContent(assetModule, CallbackUpdateComplete, CallbackUpdateFailed);
        }
Ejemplo n.º 2
0
        private static void LoadProjectAssetModules()
        {
            PROJECT_ASSET_MODULES = new Dictionary <string, AssetModule>();
            List <AssetModule> assetModules = ModuleManager.FindAssetsByType <AssetModule>();
            int assetModulesCount           = assetModules.Count;

            for (int i = 0; i < assetModulesCount; ++i)
            {
                AssetModule assetModule = assetModules[i];
                if (PROJECT_ASSET_MODULES.ContainsKey(assetModule.module.moduleID))
                {
                    Debug.LogErrorFormat(ERR_DUPLICATE, assetModule.module.moduleID);
                    continue;
                }

                PROJECT_ASSET_MODULES.Add(assetModule.module.moduleID, assetModule);

                if (!PROJECT_MODULES.ContainsKey(assetModule.module.moduleID))
                {
                    PROJECT_MODULES.Add(assetModule.module.moduleID, new ModuleManifest(
                                            assetModule.module
                                            ));

                    ModuleManager.UpdateManifest(assetModule.module);
                }
            }
        }
Ejemplo n.º 3
0
        // INITIALIZERS: --------------------------------------------------------------------------

        private void OnEnable()
        {
            this.assetModule = (AssetModule)target;

            this.spAdminLogin = serializedObject.FindProperty("adminLogin");
            this.spAdminOpen  = serializedObject.FindProperty("adminOpen");

            SerializedProperty spModule = serializedObject.FindProperty("module");

            this.spModuleID = spModule.FindPropertyRelative("moduleID");

            SerializedProperty spVersion = spModule.FindPropertyRelative("version");

            this.spVersionMajor = spVersion.FindPropertyRelative("major");
            this.spVersionMinor = spVersion.FindPropertyRelative("minor");
            this.spVersionPatch = spVersion.FindPropertyRelative("patch");

            this.spDisplayName = spModule.FindPropertyRelative("displayName");
            this.spDescription = spModule.FindPropertyRelative("description");
            this.spCategory    = spModule.FindPropertyRelative("category");

            this.spDependencies = spModule.FindPropertyRelative("dependencies");
            this.spTags         = spModule.FindPropertyRelative("tags");

            this.spAuthorName = spModule.FindPropertyRelative("authorName");
            this.spAuthorMail = spModule.FindPropertyRelative("authorMail");
            this.spAuthorSite = spModule.FindPropertyRelative("authorSite");

            this.spIncludesData = spModule.FindPropertyRelative("includesData");
            this.spCodePaths    = spModule.FindPropertyRelative("codePaths");
            this.spDataPaths    = spModule.FindPropertyRelative("dataPaths");
        }
Ejemplo n.º 4
0
        public static Texture2D GetModuleIcon(string moduleID)
        {
            if (LOAD_DATA)
            {
                ModuleManager.InitializeData();
            }
            if (ModuleManager.PROJECT_MODULES.ContainsKey(moduleID))
            {
                ModuleManifest manifest    = ModuleManager.PROJECT_MODULES[moduleID];
                AssetModule    assetModule = null;
                if (ModuleManager.PROJECT_ASSET_MODULES.ContainsKey(moduleID))
                {
                    assetModule = ModuleManager.PROJECT_ASSET_MODULES[moduleID];
                }

                if (ModuleManager.IsEnabled(manifest.module))
                {
                    if (assetModule != null && assetModule.module.version.Higher(manifest.module.version))
                    {
                        return(GetTextureModuleUpdate());
                    }

                    return(GetTextureModuleEnabled());
                }

                return(GetTextureModuleInstalled());
            }

            return(GetTextureModuleUnknown());
        }
Ejemplo n.º 5
0
        private static void DeleteModuleAsset(AssetModule assetModule)
        {
            string absolutePath        = ModuleManager.GetProjectPath();
            string relativePackagePath = Path.Combine(ASSET_MODULES_PATH, assetModule.module.moduleID);
            string absolutePackagePath = Path.Combine(absolutePath, relativePackagePath);

            if (Directory.Exists(absolutePackagePath))
            {
                FileUtil.DeleteFileOrDirectory(absolutePackagePath);
            }
        }
Ejemplo n.º 6
0
        private static void ImportModuleContent(AssetModule assetModule, AssetDatabase.ImportPackageCallback onSuccess)
        {
            string packageFilename     = string.Format(ASSET_PACK_FILENAME, assetModule.module.moduleID);
            string relativePackagePath = Path.Combine(ASSET_MODULES_PATH, assetModule.module.moduleID);

            relativePackagePath = Path.Combine(relativePackagePath, packageFilename);
            string absolutePackagePath = Path.Combine(ModuleManager.GetProjectPath(), relativePackagePath);

            if (File.Exists(absolutePackagePath))
            {
                AssetDatabase.importPackageCompleted += onSuccess;
                AssetDatabase.ImportPackage(relativePackagePath, true);
            }
        }
Ejemplo n.º 7
0
        private static void DeferredEnable()
        {
            EditorApplication.update -= DeferredEnable;

            if (ModuleManager.CURRENT_MANIFEST == null)
            {
                return;
            }
            ModuleManifest manifest = ModuleManager.CURRENT_MANIFEST;

            if (!ModuleManager.AssetModuleExists(manifest.module))
            {
                int option = EditorUtility.DisplayDialogComplex(
                    string.Format(MSG_MISSING_ASSETMODULE_TITLE, manifest.module.moduleID),
                    MSG_MISSING_ASSETMODULE_INFO,
                    "Download",
                    "Clean Manifest",
                    "Cancel"
                    );

                switch (option)
                {
                case 0:
                    Application.OpenURL(string.Format(STORE_MODULE_URI, manifest.module.moduleID));
                    break;

                case 1:
                    ModuleManager.RemoveManifest(manifest.module);
                    ModuleManager.SetDirty();
                    break;
                }

                return;
            }

            AssetModule assetModule = ModuleManager.PROJECT_ASSET_MODULES[manifest.module.moduleID];

            if (!ModuleManager.DependenciesResolved(assetModule.module))
            {
                EditorUtility.DisplayDialog(MSG_ENABLE_DEPS_TITLE, MSG_ENABLE_DEPS_INFO, "Ok");
                return;
            }

            ModuleManager.ImportModuleContent(assetModule, CallbackEnableComplete, CallbackEnableFailed);
        }
Ejemplo n.º 8
0
        private static void DeferredRemove()
        {
            EditorApplication.update -= DeferredRemove;

            if (ModuleManager.CURRENT_MANIFEST == null)
            {
                return;
            }
            ModuleManifest manifest = ModuleManager.CURRENT_MANIFEST;

            if (!ModuleManager.PROJECT_ASSET_MODULES.ContainsKey(manifest.module.moduleID))
            {
                return;
            }
            AssetModule assetModule = ModuleManager.PROJECT_ASSET_MODULES[manifest.module.moduleID];

            ModuleManager.RemoveManifest(manifest.module);
            ModuleManager.DeleteModuleAsset(assetModule);
            ModuleManager.SetDirty();
        }
Ejemplo n.º 9
0
        private static void CallbackEnableComplete(string moduleID)
        {
            AssetDatabase.importPackageCompleted -= ModuleManager.CallbackEnableComplete;
            bool keepInstaller = EditorUtility.DisplayDialog(
                MSG_ENABLE_OK_TITLE,
                MSG_ENABLE_OK_INFO,
                "Keep it",
                "Remove installer"
                );

            if (LOAD_DATA)
            {
                ModuleManager.InitializeData();
            }
            AssetModule assetModule = ModuleManager.PROJECT_ASSET_MODULES[moduleID];

            if (!keepInstaller)
            {
                ModuleManager.DeleteModuleAsset(assetModule);
            }

            ModuleManager.UpdateManifest(assetModule.module);
            ModuleManager.SetDirty();
        }
Ejemplo n.º 10
0
        // PAINT METHODS: -------------------------------------------------------------------------

        public static void PaintProjectModule(ModuleManifest manifest)
        {
            if (CURRENT_MODULE_ID != manifest.module.moduleID)
            {
                ModuleManagerContent.InitializeModule(manifest);
                CURRENT_MODULE_ID = manifest.module.moduleID;
            }

            bool        isEnabled         = ModuleManager.IsEnabled(manifest.module);
            bool        updateAvail       = ModuleManager.IsUpdateAvailable(manifest);
            bool        assetModuleExists = ModuleManager.AssetModuleExists(manifest.module);
            AssetModule assetModule       = ModuleManager.GetAssetModule(manifest.module.moduleID);

            ModuleManagerContent.PaintTitle(manifest.module);

            EditorGUILayout.BeginHorizontal(ModuleManagerContent.GetPanelStyle());
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Backup", ModuleManagerContent.GetLargeButtonStyle()))
            {
                ModuleManager.Backup(manifest);
            }

            EditorGUILayout.Space();
            EditorGUI.BeginDisabledGroup(!isEnabled || !updateAvail);
            if (GUILayout.Button("Update", ModuleManagerContent.GetLargeButtonLeft()))
            {
                ModuleManager.Update(manifest);
            }
            EditorGUI.EndDisabledGroup();

            if (!isEnabled && GUILayout.Button("Enable", ModuleManagerContent.GetLargeButtonMid()))
            {
                ModuleManager.Enable(manifest);
            }

            if (isEnabled && GUILayout.Button("Disable", ModuleManagerContent.GetLargeButtonMid()))
            {
                ModuleManager.Disable(manifest);
            }

            EditorGUI.BeginDisabledGroup(!assetModuleExists || isEnabled);
            if (GUILayout.Button("Remove", ModuleManagerContent.GetLargeButtonRight()))
            {
                ModuleManager.Remove(manifest);
            }
            EditorGUI.EndDisabledGroup();

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            ModuleManagerContent.PaintModule(manifest.module);

            EditorGUILayout.Space();
            ModuleManagerContent.PaintDependencies(
                "Dependencies ({0})",
                manifest.module.dependencies
                );

            if (updateAvail && assetModule != null)
            {
                EditorGUILayout.Space();
                ModuleManagerContent.PaintDependencies(
                    "Update Dependencies ({0})",
                    assetModule.module.dependencies
                    );
            }
        }