static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { bool hasPacakgesToInstall = false; foreach (string path in importedAssets) { if (path.Contains(MCSUpgrade.pathToPackages)) { hasPacakgesToInstall = true; break; } } if (hasPacakgesToInstall) { MCSUpgrade.UpgradeMeta meta = MCSUpgrade.GetMeta(); if (meta.autoInstallPackages) { foreach (string path in importedAssets) { if (!path.Contains(MCSUpgrade.pathToPackages)) { continue; } MCSUpgrade.InstallPackage(path); } } } }
public void OnGUI() { GUILayout.Label( "Upgrading from 1.0 to 1.6\n" + "\n\n" + "Please note, if you're upgrading from 1.0 to 1.6\n" + "this content and code is *NOT* compatible with 1.0 of MCS!\n" + "\n" + "Your project may break.\n" + "\n" + "For more info, visit https://morph3d.com" + "\n\n" ); GUIStyle style = new GUIStyle(GUI.skin.button); style.padding.top = 10; style.padding.bottom = 10; style.margin.top = 50; EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Cancel, do NOT install", style)) { Close(); return; } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Install, I'm ready to upgrade.\nDo not warn me again.", style)) { MCSUpgrade.AcceptInstall(); Close(); return; } EditorGUILayout.EndHorizontal(); }
public void Update() { if (refresh) { refresh = false; lastTime = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; AssetDatabase.Refresh(ImportAssetOptions.Default | ImportAssetOptions.ForceUpdate | ImportAssetOptions.ImportRecursive); return; } if ((packageQueue == null || packageQueue.Count <= 0) && (deleteQueue == null || deleteQueue.Count <= 0)) { return; } Int32 currentTime = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; Int32 delta = currentTime - lastTime; if (delta < 5) { //wait for later return; } lastTime = currentTime; if (packageQueue.Count > 0) { string path = packageQueue[0]; packageQueue.RemoveAt(0); bool?result = MCSUpgrade.InstallPackage(path); if (result == false) { UnityEngine.Debug.LogError("Aborting package install as: " + path + " failed to install"); packageQueue.Clear(); } else { if (result == true) { MCSUpgrade.UpgradeMeta meta = MCSUpgrade.GetMeta(); if (meta.installed == null) { meta.installed = new string[] { }; } List <string> installed = new List <string>(meta.installed); installed.Add(path); meta.installed = installed.ToArray(); MCSUpgrade.SaveMeta(meta); } deleteQueue.Add(path); } refresh = true; //wait until later return; } if (deleteQueue.Count > 0) { try { foreach (string path in deleteQueue) { if (!path.EndsWith(".unitypackage") || !File.Exists(path) || !path.Contains(MCSUpgrade.pathToPackages)) { UnityEngine.Debug.Log("Skipping: " + path); continue; } UnityEngine.Debug.Log("Removing install file: " + path); AssetDatabase.DeleteAsset(path); } } catch (Exception e) { UnityEngine.Debug.LogError("Unable to remove all install packages"); UnityEngine.Debug.LogException(e); } deleteQueue.Clear(); if (File.Exists(MCSUpgrade.pathToInstallScript)) { UnityEngine.Debug.Log("Removing installer script"); AssetDatabase.DeleteAsset(MCSUpgrade.pathToInstallScript); } Close(); } }