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); }
private void PaintContent() { this.PaintToolbar(); this.contentScroll = EditorGUILayout.BeginScrollView( this.contentScroll, GUIStyle.none, GUI.skin.verticalScrollbar ); EditorGUILayout.Space(); ModuleManifest[] manifests = ModuleManager.GetProjectManifests(); if (this.sidebarIndex < 0 || this.sidebarIndex >= manifests.Length) { ModuleManagerContent.PaintContentMessage(); } else { ModuleManifest manifest = manifests[this.sidebarIndex]; ModuleManagerContent.PaintProjectModule(manifest); } EditorGUILayout.Space(); EditorGUILayout.EndScrollView(); }
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()); }
public static void Remove(ModuleManifest manifest) { if (LOAD_DATA) { ModuleManager.InitializeData(); } CURRENT_MANIFEST = manifest; EditorApplication.update += ModuleManager.DeferredRemove; }
private void PaintContent() { this.PaintToolbar(); this.contentScroll = EditorGUILayout.BeginScrollView( this.contentScroll, GUIStyle.none, GUI.skin.verticalScrollbar ); EditorGUILayout.Space(); switch (this.toolbarOptionsIndex) { case 0: ModuleManifest[] manifests = ModuleManager.GetProjectManifests(); if (this.sidebarIndex < 0 || this.sidebarIndex >= manifests.Length) { ModuleManagerContent.PaintContentMessage(); } else { ModuleManifest manifest = manifests[this.sidebarIndex]; ModuleManagerContent.PaintProjectModule(manifest); } break; case 1: if (ModuleManagerStore.REQUEST_STATUS == ModuleManagerStore.StoreRequestStatus.Error) { ModuleManagerContent.PaintContentMessage(ModuleManagerStore.REQUEST_DATA.error); break; } else if (ModuleManagerStore.REQUEST_STATUS == ModuleManagerStore.StoreRequestStatus.Requesting) { ModuleManagerContent.PaintContentMessage("Loading..."); break; } Module[] modules = ModuleManager.GetStoreModules(); if (this.sidebarIndex < 0 || this.sidebarIndex >= modules.Length) { ModuleManagerContent.PaintContentMessage(); } else { Module module = modules[this.sidebarIndex]; ModuleManagerContent.PaintStoreModule(module); } break; } EditorGUILayout.Space(); EditorGUILayout.EndScrollView(); }
private static void DeferredDisable() { EditorApplication.update -= DeferredDisable; if (ModuleManager.CURRENT_MANIFEST == null) { return; } ModuleManifest manifest = ModuleManager.CURRENT_MANIFEST; ModuleManifest[] allManifests = ModuleManager.GetProjectManifests(); bool hasDependency = false; for (int i = 0; !hasDependency && i < allManifests.Length; ++i) { if (allManifests[i].module.moduleID == manifest.module.moduleID) { continue; } if (!ModuleManager.IsEnabled(allManifests[i].module)) { continue; } for (int j = 0; !hasDependency && j < allManifests[i].module.dependencies.Length; ++j) { if (allManifests[i].module.dependencies[j].moduleID == manifest.module.moduleID) { hasDependency = true; } } } if (hasDependency) { if (EditorUtility.DisplayDialog(MSG_DISABLE_DEPS_TITLE, MSG_DISABLE_DEPS_INFO, "Ok")) { return; } } if (EditorUtility.DisplayDialog( MSG_DISABLE_CONFIRM_TITLE, MSG_DISABLE_CONFIRM_INFO, "Yes", "Cancel")) { ModuleManager.RemoveManifest(manifest.module); ModuleManager.DeleteModuleContent(manifest.module, true); ModuleManager.SetDirty(); } }
private static void PaintDependencies(string title, Dependency[] dependencies) { EditorGUILayout.LabelField( string.Format(title, dependencies.Length), EditorStyles.boldLabel ); if (dependencies.Length > 0) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); for (int i = 0; i < dependencies.Length; ++i) { ModuleManifest depManifest = ModuleManager.GetModuleManifest( dependencies[i].moduleID ); Texture2D dot = ModuleManagerContent.GetDotG(); if (depManifest == null) { dot = ModuleManagerContent.GetDotR(); } else if (depManifest.module.version.Higher(dependencies[i].version) || !ModuleManager.IsEnabled(depManifest.module)) { dot = ModuleManagerContent.GetDotO(); } string depName = string.Format( " {0} - {1}", dependencies[i].moduleID, dependencies[i].version ); GUIContent depContent = new GUIContent(depName, dot); EditorGUILayout.LabelField(depContent); Rect depRect = GUILayoutUtility.GetLastRect(); EditorGUIUtility.AddCursorRect(depRect, MouseCursor.Link); if (UnityEngine.Event.current.type == EventType.MouseUp && depRect.Contains(UnityEngine.Event.current.mousePosition)) { Application.OpenURL(string.Format( "https://store.gamecreator.io/?search={0}", dependencies[i].moduleID )); } } EditorGUILayout.EndVertical(); } }
public static bool IsUpdateAvailable(ModuleManifest manifest) { if (LOAD_DATA) { ModuleManager.InitializeData(); } string moduleID = manifest.module.moduleID; if (ModuleManager.PROJECT_ASSET_MODULES.ContainsKey(moduleID)) { Version manifestVersion = manifest.module.version; Version assetVersion = ModuleManager.PROJECT_ASSET_MODULES[moduleID].module.version; return(assetVersion.Higher(manifestVersion)); } return(false); }
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); }
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(); }
private static void DeferredBackup() { EditorApplication.update -= DeferredBackup; if (ModuleManager.CURRENT_MANIFEST == null) { return; } ModuleManifest manifest = ModuleManager.CURRENT_MANIFEST; List <string> assetsPath = new List <string>(manifest.module.codePaths); assetsPath.AddRange(manifest.module.dataPaths); for (int i = 0; i < assetsPath.Count; ++i) { assetsPath[i] = Path.GetDirectoryName(assetsPath[i]); } string backuppath = string.Format(BACKUP_FILEPATH, DateTime.Now.ToString("yyyy-MM-dd")); string filepath = Path.Combine(ModuleManager.GetProjectPath(), backuppath); if (!Directory.Exists(filepath)) { Directory.CreateDirectory(filepath); } string filename = string.Format( BACKUP_FILENAME, manifest.module.moduleID, manifest.module.version.ToStringWithDash() ); AssetDatabase.ExportPackage( assetsPath.ToArray(), Path.Combine(filepath, filename), ExportPackageOptions.Recurse ); EditorUtility.DisplayDialog(MSG_BACKUP_TITLE, MSG_BACKUP_INFO, "Ok"); }
// 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 ); } }
// PRIVATE METHODS: ----------------------------------------------------------------------- private static void InitializeModule(ModuleManifest manifest) { ANIMBOOL_UPDATE = new AnimBool(false, ModuleManagerContent.RepaintModuleManager); ANIMBOOL_UPDATE.speed = 3.0f; }