private void InternalDrawFlags() { if (!(JEMEditorConfiguration.Configuration?.UpdateFlags ?? false)) { return; } if (_drawFlags.value) { if (GUILayout.Button("Flags (Hide)")) { _drawFlags.value = false; } } else { if (GUILayout.Button("Flags (Show)")) { _drawFlags.value = true; } } if (EditorGUILayout.BeginFadeGroup(_drawFlags.faded)) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); { for (var index = 0; index < JEMBuildFlags.Flags.Count; index++) { var flag = JEMBuildFlags.Flags[index]; if (flag.Equals(default(BuildFlag))) { continue; } EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); { GUILayout.Label(flag.Name); var enabled = EditorGUILayout.Toggle(flag.Enabled, GUILayout.Width(30)); if (enabled != flag.Enabled) { JEMBuildFlags.SetFlagActive(flag.Name, enabled); } if (GUILayout.Button("X", GUILayout.Width(30))) { JEMBuildFlags.RemoveFlag(flag.Name); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(EditorStyles.helpBox); { _newFlag = EditorGUILayout.TextField(_newFlag); if (GUILayout.Button("Add", GUILayout.Width(50))) { if (!string.IsNullOrEmpty(_newFlag) && !string.IsNullOrWhiteSpace(_newFlag)) { if (JEMBuildFlags.AddFlag(_newFlag)) { _newFlag = string.Empty; } } } } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("Force Reload")) { JEMBuildFlags.SaveFlags(); JEMBuildFlags.ApplyFlags(); } if (GUILayout.Button("Refresh/Apply")) { JEMBuildFlags.SaveFlags(); JEMBuildFlags.LoadFlags(); JEMBuildFlags.ApplyFlags(); } } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } JEMBetterEditor.FixedEndFadeGroup(_drawFlags.faded); }
/// <summary> /// Loads local data. /// </summary> public static void RefreshLocalData() { // load version info var versionData = (TextAsset)AssetDatabase.LoadAssetAtPath(VersionFile, typeof(TextAsset)); if (versionData == null) { // initialize new version file CurrentVersion = new JEMBuildVersion(); var dir = Path.GetDirectoryName(VersionFile); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir ?? throw new InvalidOperationException()); } File.WriteAllText(VersionFile, JsonConvert.SerializeObject(CurrentVersion, Formatting.Indented)); AssetDatabase.Refresh(ImportAssetOptions.Default); AssetDatabase.SaveAssets(); Debug.Log($"File {VersionFile} not exist. New file has been created."); } else { CurrentVersion = JsonConvert.DeserializeObject <JEMBuildVersion>(versionData.text); } if (CurrentVersion == null) { Debug.LogError("Unable to resolve current version data."); } // load compilation file var compilationText = !File.Exists(CompilationNumberFile) ? null : (TextAsset)AssetDatabase.LoadAssetAtPath(CompilationNumberFile, typeof(TextAsset)); if (compilationText == null) { // initialize new compilation number file CurrentCompilation = new JEMBuildCompilation(); var dir = Path.GetDirectoryName(CompilationNumberFile); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir ?? throw new InvalidOperationException()); } File.WriteAllText(CompilationNumberFile, JsonConvert.SerializeObject(CurrentCompilation, Formatting.Indented)); File.WriteAllText(LastContributorFile, JEMBuildEditor.ResolveCurrentContributorName()); AssetDatabase.Refresh(ImportAssetOptions.Default); AssetDatabase.SaveAssets(); Debug.Log($"File {CompilationNumberFile} not exist. New file has been created."); } else { CurrentCompilation = JsonConvert.DeserializeObject <JEMBuildCompilation>(compilationText.text); } if (CurrentCompilation == null) { Debug.LogError("Unable to resolve current compilation data."); } // apply compilation number CurrentCompilationNumber = JEMBuild.ResolveCurrentCompilationNumber(); CurrentBuildNumber = JEMBuild.ResolveCurrentBuildNumber(); CurrentSessionTime = JEMBuild.ResolveCurrentSessionTime(); // apply bundle version if (JEMEditorConfiguration.Configuration?.UpdateBundleVersion ?? false) { UpdateBundleVersion(); } JEMBuildFlags.LoadFlags(); JEMBuildFlags.ApplyFlags(); }