public static void Clear() { if (progressOpen) { EditorUtility.ClearProgressBar(); progressOpen = false; } top = null; }
/// <summary> /// Update the progress in editor. /// </summary> public static void UpdateProgress() { if (isLoadDoc && !hasLoadDoc) { EditorProgressBar.ShowProgressBar("Loading Documentation", progress); } else { EditorProgressBar.ClearProgressBar(); } }
public void Close() { if (_parent != null) { _parent._child = null; _parent = null; } else if (top == this) { top = null; Update(); } }
public static void ReindexAll() { var gameManager = AssetDatabase.LoadAssetAtPath <GameManager>("Assets/Assets/Engine/GameManager.prefab"); if (gameManager == null) { Debug.LogError("StaticAsset index failed, could not load Assets/Engine/GameManager.prefab!"); return; } if (gameManager.staticData != null) { var progress = new EditorProgressBar("Re-indexing Bowhead Assets...", 3); List <Object> indexedObjects = (gameManager.staticData.indexedObjects != null) ? new List <Object>(gameManager.staticData.indexedObjects) : new List <Object>(); bool changed; changed = IndexAssetTypes(typeof(StaticAsset), indexedObjects); progress.Step(null); changed = IndexAssetTypes(typeof(StaticVersionedAsset), indexedObjects) || changed; progress.Step(null); changed = IndexAssetTypes(typeof(StaticVersionedAssetWithSerializationCallback), indexedObjects) || changed; progress.Close(); for (int i = 0; i < indexedObjects.Count; ++i) { var obj = indexedObjects[i] as StaticAsset.Indexed; if ((obj != null) && (obj.staticIndex != i)) { indexedObjects[i] = null; changed = true; } else if ((obj == null) && (indexedObjects[i] != null)) // asset was static indexed but now just a ScriptableObject. { indexedObjects[i] = null; changed = true; } } if (changed) { if (changed) { gameManager.staticData.indexedObjects = indexedObjects.ToArray(); } EditorUtility.SetDirty(gameManager.staticData); } } }
public static void ApplyPrefabPanel(PrefabPanel panel) { EditorProgressBar.ShowProgressBar("Applying prefabs ...", 0); int i = 0; foreach (GameObject item in panel.gameObject.GetEnumerator()) { GameObject prefab = item.GetEnumerator().First(); PrefabUtility.ReplacePrefab(prefab, PrefabUtility.GetCorrespondingObjectFromSource(prefab)); i++; EditorProgressBar.ShowProgressBar("Applying prefabs ...", i / (i + 1.0f)); } EditorProgressBar.ShowProgressBar("Applying prefabs ...", 1.0f); EditorProgressBar.ClearProgressBar(); }
static bool IndexAssetTypes(Type t, List <Object> indexedObjects) { bool changed = false; var guids = AssetDatabase.FindAssets("t:" + t.Name); if (guids.Length > 0) { var progress = new EditorProgressBar(null, guids.Length + 1); foreach (var guid in guids) { var path = AssetDatabase.GUIDToAssetPath(guid); progress.Step(path); changed = IndexAssetAtPath(path, indexedObjects) || changed; } progress.Step(null); } return(changed); }
public EditorProgressBar(string description, int numSteps) { _numSteps = numSteps; _parent = top; if (_parent != null) { while (_parent._child != null) { _parent = _parent._child; } } _description = description; if (_parent != null) { _parent._child = this; } else { top = this; } Update(); }
bool BuildPlatform(Platform p) { var progress = new EditorProgressBar(null, p.targets.Length * 2); foreach (var target in p.targets) { progress.description = "Building " + p.name + " - [" + target + "]"; var buildPath = Platform.GetTargetPath(target); try { RecursiveDeleteDirectory(buildPath); } catch (Exception e) { if (!(e is DirectoryNotFoundException)) { Debug.LogException(e); EditorUtility.DisplayDialog("Error", "Unable to clean build path: '" + buildPath + "' for " + p.name, "OK"); progress.Close(); return(false); } } try { Directory.CreateDirectory(buildPath); } catch (Exception e) { Debug.LogException(e); EditorUtility.DisplayDialog("Error", "Unable to create build path: '" + buildPath + "' for " + p.name, "OK"); progress.Close(); return(false); } List <string> levels = new List <string>(); for (int i = 0; i < STATIC_LEVELS.Length; ++i) { levels.Add(STATIC_LEVELS[i]); } for (int i = 0; i < GameManager.LEVELS.Count; ++i) { var level = GameManager.LEVELS[i]; levels.Add("Assets/Scenes/" + level.name + "/" + level.name + ".unity"); for (int k = 0; k < level.sublevels.Length; ++k) { levels.Add("Assets/Scenes/" + level.name + "/" + level.sublevels[k] + ".unity"); } } BuildOptions options = BuildOptions.ForceEnableAssertions; var buildFlags = scriptFlags; if (buildFlags.Contains("PROFILING")) { options |= BuildOptions.Development; } if (p.deployment == EDeploymentType.BackendServer) { options |= BuildOptions.EnableHeadlessMode; buildFlags = BuildOptionsWindow.AddDefine(buildFlags, "DEDICATED_SERVER"); buildFlags = BuildOptionsWindow.AddDefine(buildFlags, "BACKEND_SERVER"); buildFlags = BuildOptionsWindow.RemoveDefine(buildFlags, "LOGIN_SERVER"); buildFlags = BuildOptionsWindow.RemoveDefine(buildFlags, "STEAM_API"); } if (buildFlags != PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone)) { PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, buildFlags); } var report = BuildPipeline.BuildPlayer(levels.ToArray(), Platform.GetAppPath(target), target, options); // TODO: //if (!string.IsNullOrEmpty(err)) { // EditorUtility.DisplayDialog("Error", err, "OK"); // progress.Close(); // return false; //} if (p.deployment == EDeploymentType.BackendServer) { if (!CopyTelemetry(buildPath)) { EditorUtility.DisplayDialog("Error", "Failed to copy telemetry.", "OK"); progress.Close(); return(false); } } RecursiveClearReadonlyState(buildPath); if (target == BuildTarget.StandaloneWindows) { // need to copy steam over... try { File.Move(Path.Combine(Platform.GetTargetPath(target), "Deadhold_Data/Plugins/steam_api.dll"), Path.Combine(Platform.GetTargetPath(target), "steam_api.dll")); } catch (Exception) { } } progress.Step(null); if (BuildOptionsWindow.IsDefined(buildFlags, "SHIP")) { progress.description = "Obfuscating " + p.name + " [" + target + "]"; if (!ObfuscateAssembly(Platform.GetAssemblyPath(target))) { progress.Close(); return(false); } } progress.Step(null); } return(true); }
bool Publish() { var steamTempPath = Utils.projectRootDirectory + "/Build/Steam/steamcmd/temp"; var steamCmdPath = Utils.projectRootDirectory + "/Build/Steam/steamcmd"; try { Directory.CreateDirectory(steamTempPath); Directory.CreateDirectory(steamCmdPath); } catch (Exception e) { Debug.LogException(e); EditorUtility.DisplayDialog("Error", "Unable to create temp folder: '" + steamTempPath, "OK"); return(false); } steamCmdPath += "/steamcmd.exe"; bool builtOne = false; foreach (var platform in PLATFORMS) { if (platform.shouldBuild) { builtOne = true; if (!WritePlatformVDFs(platform)) { return(false); } } } if (builtOne) { try { if (!File.Exists(steamCmdPath)) { File.Copy(Utils.projectRootDirectory + "/steamcmd/steamcmd.exe", steamCmdPath); } } catch (Exception e) { Debug.LogException(e); EditorUtility.DisplayDialog("Error", "Unable to copy steamcmd.exe", "OK"); return(false); } var buildId = GetBuildID(); if (buildId == null) { return(false); } { var prefix = string.Empty; foreach (var platform in PLATFORMS) { if (platform.shouldBuild) { prefix += "[" + platform.name + "]"; } } if (!string.IsNullOrEmpty(prefix)) { buildId = prefix + " " + buildId; } } List <int> appIds = new List <int>(); foreach (var p in PLATFORMS) { if (p.shouldBuild) { foreach (int appId in p.appIds) { if (!appIds.Contains(appId)) { appIds.Add(appId); } } } } foreach (var appId in appIds) { var appConfigFilePath = Utils.projectRootDirectory + "/Build/Steam/steamcmd/app.vdf"; try { using (var file = new StreamWriter(appConfigFilePath, false, System.Text.Encoding.ASCII)) { file.WriteLine("\"appbuild\""); file.WriteLine("{"); file.WriteLine("\t\"appid\" \"" + appId + "\""); file.WriteLine("\t\"desc\" \"" + buildId + "\""); file.WriteLine("\t\"buildoutput\" \"" + steamTempPath + "\""); file.WriteLine("\t\"setlive\" \"" + branch + "\""); file.WriteLine("\t\"preview\" \"0\""); file.WriteLine("\t\"local\" \"\""); file.WriteLine("\t\"depots\""); file.WriteLine("\t{"); foreach (var platform in PLATFORMS) { if (platform.shouldBuild && platform.appIds.Contains(appId)) { foreach (var depotId in platform.depotIds) { var depotConfigFile = "depot_" + depotId + ".vdf"; file.WriteLine("\t\t\"" + depotId + "\" \"" + depotConfigFile + "\""); } } } file.WriteLine("\t}"); file.WriteLine("}"); } } catch (Exception e) { Debug.LogException(e); EditorUtility.DisplayDialog("Error", "Error writing steam configuration file for application: " + appConfigFilePath, "OK"); return(false); } var progress = new EditorProgressBar("Uploading to Steam", 1); if (!RunSteamCmd(steamCmdPath, appConfigFilePath)) { progress.Close(); return(false); } progress.Step(null); } if (IncrementBuildNumber()) { if (!CommitBuildNumber(buildId)) { EditorUtility.DisplayDialog("Error", "Error updating build number", "OK"); RevertBuildNumber(); } } else { RevertBuildNumber(); } } else { EditorUtility.DisplayDialog("Error", "No platforms are selected.", "OK"); return(false); } return(true); }
bool Build() { bool builtOne = false; var buildId = GetBuildID(); if (buildId == null) { return(false); } if (!WriteBuildInfo(buildId)) { return(false); } var numThatWillBuild = 0; foreach (var platform in PLATFORMS) { if (platform.shouldBuild) { ++numThatWillBuild; } } if (numThatWillBuild < 1) { EditorUtility.DisplayDialog("Error", "There are platforms selected.", "OK"); return(false); } var progress = new EditorProgressBar(null, numThatWillBuild); Platform toSkip = null; foreach (var platform in PLATFORMS) { if (platform.shouldBuild) { foreach (var target in platform.targets) { if (EditorUserBuildSettings.activeBuildTarget == target) { toSkip = platform; break; } } } if (toSkip != null) { progress.description = platform.name; builtOne = true; if (!BuildPlatform(platform)) { #if PERFORCE P4RevertFile(buildInfoPath); #else SVNRevertFile(buildInfoPath); #endif progress.Close(); return(false); } progress.Step(null); break; } } foreach (var platform in PLATFORMS) { if (platform.shouldBuild && (platform != toSkip)) { progress.description = platform.name; builtOne = true; if (!BuildPlatform(platform)) { #if PERFORCE P4RevertFile(buildInfoPath); #else SVNRevertFile(buildInfoPath); #endif progress.Close(); return(false); } progress.Step(null); } } #if PERFORCE P4RevertFile(buildInfoPath); #else SVNRevertFile(buildInfoPath); #endif return(builtOne); }
void OnGUI() { EditorGUILayout.BeginVertical(); GUILayoutHelpers.HorzLine(); { var s = BuildOptionsWindow.OnGUI_ScriptFlags(scriptFlags, true); if (s != scriptFlags) { EditorPrefs.SetString("steamscriptflags", s); scriptFlags = s; } } GUILayoutHelpers.HorzLine(); OnGUI_BuildPlatforms(); GUILayoutHelpers.HorzLine(); #if PERFORCE EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayoutHelpers.CenterLabel("Perforce"); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); { var s = EditorGUILayout.TextField("P4 Directory", p4path); if (s != p4path) { EditorPrefs.SetString("p4path", s); p4path = s; } s = EditorGUILayout.TextField("P4 Server", p4server); if (s != p4server) { EditorPrefs.SetString("p4server", s); p4server = s; } s = EditorGUILayout.TextField("P4 User", p4user); if (s != p4user) { EditorPrefs.SetString("p4user", s); p4user = s; } s = EditorGUILayout.PasswordField("P4 Password", p4pass); if (s != p4pass) { EditorPrefs.SetString("p4pass", s); p4pass = s; } s = EditorGUILayout.TextField("P4 Workspace", p4client); if (s != p4client) { EditorPrefs.SetString("p4client", s); p4client = s; } } GUILayoutHelpers.HorzLine(); #endif EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayoutHelpers.CenterLabel("Steam"); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); { var i = 0; while ((branch != BRANCHES[i]) && (i < BRANCHES.Length)) { ++i; } if (i >= BRANCHES.Length) { i = 0; } var s = EditorGUILayout.Popup("Set Live", i, BRANCHES); if (s != i) { branch = BRANCHES[s]; EditorPrefs.SetString("steambranch", branch); } } { var s = EditorGUILayout.TextField("Steam Login", steamLogin); if (s != steamLogin) { EditorPrefs.SetString("steamlogin", s); steamLogin = s; } } { var s = EditorGUILayout.PasswordField("Steam Password", steamPassword); if (s != steamPassword) { EditorPrefs.SetString("steampass", s); steamPassword = s; } } GUILayoutHelpers.HorzLine(); bool build = false; if (GUILayout.Button("Build (testing only!)...")) { build = true; } bool publish = false; if (GUILayout.Button("Build and Publish...")) { publish = true; build = true; } //if (GUILayout.Button("Retry Publish (careful!)...")) { // publish = true; //} EditorGUILayout.EndVertical(); string oldScriptFlags = null; if (build || publish) { #if PERFORCE if (string.IsNullOrEmpty(p4path) || string.IsNullOrEmpty(p4server) || string.IsNullOrEmpty(p4user) || string.IsNullOrEmpty(p4pass) || string.IsNullOrEmpty(p4client)) { EditorUtility.DisplayDialog("Error", "Please fill in the perforce fields to build for Steam.", "OK"); return; } #endif oldScriptFlags = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone); } if (build && publish) { var progress = new EditorProgressBar("Building...", 2); var r = CheckForPrereqs() && Build(); if (r) { progress.Step("Publishing..."); r = Publish(); progress.Step(null); } else { progress.Close(); } if (r) { EditorUtility.DisplayDialog("Success", "Build and publish completed successfully.", "OK"); } else { EditorUtility.DisplayDialog("Error", "Build failed.", "OK"); } } else if (build) { var progress = new EditorProgressBar("Building...", 1); var r = CheckForPrereqs() && Build(); progress.Step(null); if (r) { EditorUtility.DisplayDialog("Success", "Build completed successfully.", "OK"); } else { EditorUtility.DisplayDialog("Error", "Build failed.", "OK"); } } else if (publish) { var progress = new EditorProgressBar("Publishing...", 1); var r = CheckForPrereqs(); if (r) { progress.Step("Publishing..."); r = Publish(); progress.Step(null); } else { progress.Close(); } if (r) { EditorUtility.DisplayDialog("Success", "Publish completed successfully.", "OK"); } else { EditorUtility.DisplayDialog("Error", "Publish failed.", "OK"); } } if (build || publish) { if (oldScriptFlags != PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone)) { PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, oldScriptFlags); } } }
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths) { if (!autoUpdateWeakRefs) { return; } if ((deletedAssets.Length > 0) || (movedAssets.Length > 0)) { bool anyDeleted = false; bool anyMoved = false; { foreach (var path in deletedAssets) { if (path.Contains("Resources/")) { anyDeleted = true; break; } } if (!anyDeleted) { foreach (var path in movedFromAssetPaths) { if (path.Contains("Resources/")) { anyMoved = true; break; } } } } if (!(anyMoved || anyDeleted)) { return; } LoadClasses(); if (_classes == null) { return; } var paths = AssetDatabase.GetAllAssetPaths(); if (paths.Length > 0) { var progress = new EditorProgressBar("Bowhead: Updating Asset References...", 1); var subProgress = new EditorProgressBar(null, paths.Length); foreach (var path in paths) { if ((path.Contains(".asset") || path.Contains(".prefab")) && !path.StartsWith("Assets/ThirdParty/")) { subProgress.Step(path); var objs = AssetDatabase.LoadAllAssetsAtPath(path); foreach (var obj in objs) { if (obj != null) { WeakRefField field; if (_classes.TryGetValue(obj.GetType(), out field)) { bool deleted = false; if (anyDeleted) { for (int i = 0; i < deletedAssets.Length; ++i) { if (FixupDelete(obj, field, deletedAssets[i])) { deleted = true; } } } bool moved = false; if (anyMoved) { for (int i = 0; i < movedAssets.Length; ++i) { if (FixupMove(obj, field, movedFromAssetPaths[i], movedAssets[i])) { moved = true; } } } if (moved || deleted) { EditorUtility.SetDirty(obj); } } } } } else { subProgress.Step(null); } } progress.Step(null); EditorUtility.UnloadUnusedAssetsImmediate(); } } }