protected virtual void OnGUI() { if (this.richTextField == null) { this.richTextField = new GUIStyle(GUI.skin.textField); this.richTextField.richText = true; } using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button(LC.G("ImportSettings_Import")) == true) { ImportSettingsWizard.trackObjects.Clear(); try { this.Import(this.root); InternalNGDebug.Log(LC.G("ImportSettings_ImportCompleted")); } catch (Exception ex) { InternalNGDebug.LogException(LC.G("ImportSettings_ImportFailed"), ex); } } } ImportSettingsWizard.trackObjects.Clear(); this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition); { this.DrawNode(this.root); } EditorGUILayout.EndScrollView(); }
protected virtual void OnGUI() { if (this.richTextField == null) { this.richTextField = new GUIStyle(GUI.skin.textField); this.richTextField.richText = true; } this.DrawWizardGUI(); using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button(LC.G("ExportSettings_Export")) == true) { if (SettingsExporter.Export(this.instances, this.root, exportFile) == true) { InternalNGDebug.Log(LC.G("ExportSettings_ExportSuccess")); } else { InternalNGDebug.LogError(LC.G("ExportSettings_ExportFailed")); } } } this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition); this.DrawNode(this.root); EditorGUILayout.EndScrollView(); }
private static void Create(Type type) { try { string path = string.Empty; if (ScriptableObjectCreator.contextObject != null) { path = AssetDatabase.GetAssetPath(ScriptableObjectCreator.contextObject); if (string.IsNullOrEmpty(path) == false && Directory.Exists(path) == false) { path = Directory.GetParent(path).FullName; } } path = EditorUtility.SaveFilePanelInProject(LC.G("Create") + " " + type.Name, type.Name + ".asset", "asset", LC.G("ScriptableObjectCreator_EnterAssetName"), path); if (string.IsNullOrEmpty(path) == false) { ScriptableObject instance = ScriptableObject.CreateInstance(type); AssetDatabase.CreateAsset(instance, path); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); Selection.activeObject = instance; } } catch (Exception ex) { InternalNGDebug.LogException(ex); } }
public override float GetHeight() { string content = LC.G((base.attribute as LocaleHeaderAttribute).key); if (string.IsNullOrEmpty(content) == false) { return((base.attribute as LocaleHeaderAttribute).height); } return(0F); }
protected virtual void OnGUI() { this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition); { GUILayout.Label(LC.G("Tips_Title"), GeneralStyles.MainTitle); GUILayout.Label(LC.G("Tips_Introduction"), GeneralStyles.InnerBoxText); for (int i = 0; i < TipsWindow.tipLCKeys.Count; i++) { GUILayout.Label((i + 1).ToString() + " - " + LC.G("Tip_" + TipsWindow.tipLCKeys[i] + "_Title"), "HeaderLabel"); GUILayout.Label(LC.G("Tip_" + TipsWindow.tipLCKeys[i] + "_Content"), GeneralStyles.InnerBoxText); } } EditorGUILayout.EndScrollView(); }
public override void OnGUI(Rect position) { string content = LC.G((base.attribute as LocaleHeaderAttribute).key); if (string.IsNullOrEmpty(content) == true) { return; } float h = (base.attribute as LocaleHeaderAttribute).height; if (h - EditorStyles.boldLabel.lineHeight >= 0F) { position.y += h - EditorStyles.boldLabel.lineHeight; } position = EditorGUI.IndentedRect(position); GUI.Label(position, LC.G((base.attribute as LocaleHeaderAttribute).key), EditorStyles.boldLabel); }
private void DrawNode(ImportNode node) { node.UpdateInstance(); if (node.parent != null && node.node.options == SettingsExporter.Node.Option.Normal) { EditorGUILayout.BeginHorizontal(); { GUILayout.Space((GUI.depth - 1) * 16F); EditorGUILayout.BeginVertical(); { bool hasParentAddImportOption = node.HasParentAddImportOption(); EditorGUILayout.BeginHorizontal(); { node.isImported = GUILayout.Toggle(node.isImported, Utility.NicifyVariableName(node.node.name)); if (node.instanceType == null) { GUILayout.Label("<color=yellow>" + string.Format(LC.G("ImportSettings_TypeIsUnknown"), node.node.name) + "</color>", this.richTextField); node.isImported = false; } else if (node.instance == null && node.parent.parent == null) // Root instance is missing. { GUILayout.Label("<color=yellow>" + string.Format(LC.G("ImportSettings_NoInstanceOfTypeFound"), node.node.name) + "</color>", this.richTextField); node.isImported = false; } else { // Do not show array, but since string is an array... if (typeof(IEnumerable).IsAssignableFrom(node.instanceType) == false || node.instanceType == typeof(string)) { // Overwrite is available only if parents are not adding. if (hasParentAddImportOption == false) { if (string.IsNullOrEmpty(node.node.value) == false) { if (typeof(Object).IsAssignableFrom(node.instanceType) == true) { Object o = node.instance as Object; string GUID = AssetDatabase.GetAssetPath(o); GUID = AssetDatabase.AssetPathToGUID(GUID); // New value will overwrite. if (node.node.value != GUID) { GUILayout.Label("<color=grey>" + node.instance + "</color> < <color=green>" + node.node.value + "</color>", this.richTextField); } // Values are equal. else { GUILayout.Label("<color=grey>" + node.node.value + "</color>", this.richTextField); } } else if (node.instance != null) { // New value will overwrite. if (node.node.value != node.instance.ToString()) { GUILayout.Label("<color=grey>" + node.instance + "</color> < <color=green>" + node.node.value + "</color>", this.richTextField); } // Values are equal. else { GUILayout.Label("<color=grey>" + node.node.value + "</color>", this.richTextField); } } // New value. else if (string.IsNullOrEmpty(node.node.value) == false) { GUILayout.Label("<color=cyan>" + node.node.value + "</color>", this.richTextField); } } } // New value. else if (string.IsNullOrEmpty(node.node.value) == false) { GUILayout.Label("<color=cyan>" + node.node.value + "</color>", this.richTextField); } } if (node.fieldInfo == null && // Remove options from root and fields, they can only be overwritten. (node.arrayExportOptions & ExportableAttribute.ArrayOptions.Immutable) == 0) // Hide it from Immutable classes and arrays. e.g. MainLog can only be overwritten. { // When a parent is adding, children can only be added (Without changing the import option). if (hasParentAddImportOption == true) { EditorGUI.BeginDisabledGroup(true); { EditorGUILayout.EnumPopup(string.Empty, ArrayImportOption.Add); // LC.G("Options") } EditorGUI.EndDisabledGroup(); } else { node.arrayImportOption = (ArrayImportOption)EditorGUILayout.EnumPopup(string.Empty, node.arrayImportOption); } } GUILayout.FlexibleSpace(); } } EditorGUILayout.EndHorizontal(); // Check if the node has an instance to overwrite. Of course, when a parent is adding, there is no overwrite anymore. if (hasParentAddImportOption == false && node.arrayImportOption == ArrayImportOption.Overwrite && node.instance == null) { GUILayout.Label("<color=yellow>" + LC.G("ImportSettings_CantOverwriteInstance") + "</color>", "CN EntryWarn"); if (node.isImported == true) { node.arrayImportOption = ArrayImportOption.Add; } } } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); } if (node.isImported == false || node.children == null) { return; } if (node.parent != null) { ++GUI.depth; } for (int i = 0; i < node.children.Length; i++) { this.DrawNode(node.children[i]); } if (node.parent != null) { --GUI.depth; } }
protected virtual void OnGUI() { if (string.IsNullOrEmpty(this.requestError) == false) { EditorGUILayout.HelpBox(this.requestError, MessageType.Error); } GUILayout.Label(LC.G("ContactFormWizard_Title"), GeneralStyles.MainTitle); this.contactName = EditorGUILayout.TextField(LC.G("ContactFormWizard_ContactName"), this.contactName); if (string.IsNullOrEmpty(this.contactName) == true) { EditorGUILayout.HelpBox(LC.G("ContactFormWizard_NameRequired"), MessageType.Warning); } this.contactEMail = EditorGUILayout.TextField(LC.G("ContactFormWizard_ContactEMail"), this.contactEMail); if (Regex.IsMatch(this.contactEMail, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase) == false) { EditorGUILayout.HelpBox(LC.G("ContactFormWizard_ValidEMailRequired"), MessageType.Warning); } this.subject = (Subject)EditorGUILayout.EnumPopup("Subject", this.subject); this.specificTools = EditorGUILayout.TextField("Specific Tools", this.specificTools); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Add information about", GUILayoutOptionPool.Width(145F)); this.packageInformation = GUILayout.Toggle(this.packageInformation, "Package", "ButtonLeft"); Rect r2 = GUILayoutUtility.GetLastRect(); r2.x += 2F; r2.y += 1F; GUI.Toggle(r2, this.packageInformation, string.Empty); this.unityInformation = GUILayout.Toggle(this.unityInformation, LC.G("ContactFormWizard_UnityInformation"), "ButtonMid"); r2 = GUILayoutUtility.GetLastRect(); r2.x += 2F; r2.y += 1F; GUI.Toggle(r2, this.unityInformation, string.Empty); this.osInformation = GUILayout.Toggle(this.osInformation, LC.G("ContactFormWizard_OSInformation"), "ButtonMid"); r2 = GUILayoutUtility.GetLastRect(); r2.x += 2F; r2.y += 1F; GUI.Toggle(r2, this.osInformation, string.Empty); this.hardwareInformation = GUILayout.Toggle(this.hardwareInformation, LC.G("ContactFormWizard_HardwareInformation"), "ButtonRight"); r2 = GUILayoutUtility.GetLastRect(); r2.x += 2F; r2.y += 1F; GUI.Toggle(r2, this.hardwareInformation, string.Empty); } EditorGUILayout.EndHorizontal(); Rect r = this.position; r.x = 0F; r.y = 20F; r.height -= 20F; Utility.content.text = this.complementaryInformation; EditorGUILayout.LabelField(LC.G("ContactFormWizard_ComplementaryInformation")); this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition); { this.complementaryInformation = EditorGUILayout.TextArea(this.complementaryInformation, GUI.skin.textArea, GUILayoutOptionPool.ExpandWidthTrue, GUILayoutOptionPool.ExpandHeightTrue); } GUILayout.EndScrollView(); if (this.subject == Subject.BugReport) { if (this.packageInformation == false || this.unityInformation == false || this.osInformation == false || this.hardwareInformation == false) { EditorGUILayout.HelpBox(LC.G("ContactFormWizard_BugReportRecommendation"), MessageType.Info); } } EditorGUILayout.HelpBox(LC.G("ContactFormWizard_SupportLanguagesWarning"), MessageType.Info); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("Preview", GUILayoutOptionPool.Width(this.position.width * .45F)) == true) { string tempFilePath = Path.Combine(Application.temporaryCachePath, Path.GetRandomFileName() + ".txt"); File.WriteAllText(tempFilePath, this.PrepareTheEmail()); EditorUtility.OpenWithDefaultApp(tempFilePath); } GUILayout.FlexibleSpace(); using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (this.requesting == true) { GUILayout.Button("Requesting...", GUILayoutOptionPool.Width(this.position.width * .5F)); GUI.Label(GUILayoutUtility.GetLastRect(), GeneralStyles.StatusWheel); this.Repaint(); } else { EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(this.contactName) || string.IsNullOrEmpty(this.contactEMail)); { if (GUILayout.Button("Send", GUILayoutOptionPool.Width(this.position.width * .45F)) == true) { this.SendEmail(); } } EditorGUI.EndDisabledGroup(); } } } EditorGUILayout.EndHorizontal(); }
internal static void SetNestedMode(object value) { if (EditorApplication.isPlaying == true) { EditorUtility.DisplayDialog(Constants.PackageTitle, LC.G("Preferences_WarningPlayMode"), LC.G("Ok")); return; } if ((bool)value == true) { StringBuilder buffer = Utility.GetBuffer(); buffer.Append(@"// File auto-generated by " + Constants.PackageTitle + @". using UnityEditor; namespace NGToolsEditor { internal static class ExternalNGMenuItems { public const string MenuItemPath = Constants.PackageTitle + ""/"";" ); int p = buffer.Length; buffer.Append(@" " ); Type externalNGMenuItems = Type.GetType("NGToolsEditor.ExternalNGMenuItems"); foreach (Type t in Utility.EachAllSubClassesOf(typeof(object), (Assembly a) => a.FullName.StartsWith("NG") || a.FullName.StartsWith("Assembly-"), (Type t) => t != null && t != externalNGMenuItems && t.Namespace != null && t.Namespace.StartsWith("NG"))) { foreach (MethodInfo m in t.GetMethods(BindingFlags.Static | BindingFlags.Public)) { if (m.IsDefined(typeof(MenuItem), false) == true) { MenuItem[] attributes = m.GetCustomAttributes(typeof(MenuItem), false) as MenuItem[]; for (int i = 0; i < attributes.Length; i++) { if (attributes[i].menuItem.StartsWith(Constants.MenuItemPath) == false || attributes[i].menuItem.Contains(NGHotkeys.SubMenuItemPath) == true) { continue; } string label = '"' + attributes[i].menuItem.Substring(Constants.MenuItemPath.Length) + '"'; buffer.Append(@" [MenuItem(ExternalNGMenuItems.MenuItemPath + " + label + ", priority = " + attributes[i].priority + @")] public static void " + t.Name + m.Name + @"() { HQ.Invoke(ExternalNGMenuItems.MenuItemPath + " + label + ", Utility.GetType(\"" + t.Namespace + "\", \"" + t.Name + "\"), \"" + m.Name + @"""); }" ); } } } } buffer.Append(@" } }"); if (Directory.CreateDirectory(HQ.RootPath + "/Editor") != null) { File.WriteAllText(HQ.RootPath + "/Editor/" + HQ.NestedNGMenuItems, Utility.ReturnBuffer(buffer)); Utility.RecompileUnityEditor(); } } else { string[] files = Directory.GetFiles(HQ.RootPath, HQ.NestedNGMenuItems, SearchOption.AllDirectories); if (files.Length == 1) { AssetDatabase.MoveAssetToTrash(files[0]); string parentFolder = Path.GetDirectoryName(files[0]); if (Directory.GetFiles(parentFolder).Length == 0 && Directory.GetDirectories(parentFolder).Length == 0) { Directory.Delete(parentFolder); } } } }
private static void CheckSettingsVersion() { if (HQ.settings != null && HQ.settings.version != NGSettings.Version) { EditorApplication.delayCall += () => { if (EditorUtility.DisplayDialog(Constants.PackageTitle, string.Format(LC.G("Preferences_AskResetSettings"), HQ.settings.version, NGSettings.Version), LC.G("Yes"), LC.G("No")) == true) { GUICallbackWindow.Open(() => { SerializedObject obj = new SerializedObject(HQ.settings); NGSettings newSettings = ScriptableObject.CreateInstance <NGSettings>(); newSettings.hideFlags = HQ.settings.hideFlags; if (NGSettings.sharedSettings == HQ.settings) { File.Delete(NGSettings.GetSharedSettingsPath()); NGSettings.sharedSettings = newSettings; } SerializedObject newObject = new SerializedObject(newSettings); SerializedProperty it = obj.GetIterator(); it.Next(true); SerializedProperty end = it.GetEndProperty(); while (SerializedProperty.EqualContents(it, end) == false && it.Next(true) == true) { newObject.CopyFromSerializedProperty(it); } newObject.ApplyModifiedProperties(); string path = AssetDatabase.GetAssetPath(HQ.settings.GetInstanceID()); if (string.IsNullOrEmpty(path) == false) { AssetDatabase.CreateAsset(newSettings, path); } HQ.settings = newSettings; if (HQ.SettingsChanged != null) { HQ.SettingsChanged(); } }); } }; } }
protected virtual void OnGUI() { if (this.GUIOnce == false && Event.current.type == EventType.Repaint) { this.GUIOnce = true; GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); this.ProcessMaxNamespaceWidth(this.types); this.allNamespaceWidth = this.namespaceWidth; this.allNameWidth = this.nameWidth; } GUILayout.BeginHorizontal(GeneralStyles.Toolbar); { EditorGUI.BeginChangeCheck(); using (BgColorContentRestorer.Get(this.temporaryFilterTypes.Count == 0 && string.IsNullOrEmpty(this.filter) == false, Color.red)) { if (Event.current.type == EventType.KeyDown) { if (Event.current.keyCode == KeyCode.Escape) { GUI.FocusControl(null); } else if (Event.current.keyCode == KeyCode.KeypadEnter || Event.current.keyCode == KeyCode.Return) { if (this.EnableNullValue == true || this.SelectedType != null) { this.Create(this.SelectedType); } } else if (Event.current.keyCode == KeyCode.Home) { GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); this.SelectedType = null; this.scrollWitnessOnce = false; this.scrollbar.Offset = 0F; this.scrollbar.ClearInterests(); this.Repaint(); } else if (Event.current.keyCode == KeyCode.End) { GUI.FocusControl(null); if (this.EnableCategories == true) { foreach (var pair in this.categories) { this.SelectedType = pair.Value[pair.Value.Count - 1]; } } else if (string.IsNullOrEmpty(this.filter) == true) { this.SelectedType = this.types[this.types.Length - 1]; } else { this.SelectedType = this.displayingTypes[this.displayingTypes.Count - 1]; } this.scrollWitnessOnce = false; this.scrollbar.Offset = float.MaxValue; this.scrollbar.ClearInterests(); this.Repaint(); } else if (Event.current.keyCode == KeyCode.PageUp || Event.current.keyCode == KeyCode.UpArrow) { int shift = Event.current.keyCode == KeyCode.PageUp ? (int)((this.position.height - Constants.SingleLineHeight) / Constants.SingleLineHeight) : 1; if (this.SelectedType == null) { GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); this.scrollbar.Offset = 0F; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); } else if (this.EnableCategories == true) { this.lastTypes.Clear(); this.lastOffsets.Clear(); float shiftOffset = Event.current.keyCode == KeyCode.PageUp ? this.position.height - Constants.SingleLineHeight : Constants.SingleLineHeight; float offset = 0F; float lastHeight = 0F; Type lastType = null; foreach (var pair in this.categories) { for (int i = 0; i < pair.Value.Count; i++) { if (pair.Value[i] == this.SelectedType) { float targetOffset = offset + Constants.SingleLineHeight - shiftOffset; if (i == 0) { targetOffset += GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; } if (this.lastOffsets.Count > 0) { int j = 0; for (j = this.lastOffsets.Count - 1; j >= 0; j--) { if (targetOffset > this.lastOffsets[j]) { if (j + 1 < this.lastOffsets.Count) { lastHeight = this.lastOffsets[j + 1] - this.lastOffsets[j]; } else { lastHeight = offset - this.lastOffsets[j]; } lastType = this.lastTypes[j]; offset = this.lastOffsets[j]; goto bigBreak; } } lastType = this.lastTypes[0]; offset = 0F; } else { GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); lastType = null; offset = 0F; } bigBreak: if (this.SelectedType != lastType) { this.SelectedType = lastType; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); } if (offset < this.scrollbar.Offset) { this.scrollbar.Offset = offset; } else if (offset + lastHeight > this.scrollbar.Offset + this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + offset + lastHeight; } this.Repaint(); return; } this.lastOffsets.Add(offset); this.lastTypes.Add(pair.Value[i]); if (i == 0) { offset += GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; } offset += Constants.SingleLineHeight; } } } else if (string.IsNullOrEmpty(this.filter) == true) { for (int i = 0; i < this.types.Length; i++) { if (this.types[i] == this.SelectedType) { if (i == 0) { GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); this.SelectedType = null; } else { i = Mathf.Max(0, i - shift); this.SelectedType = this.types[i]; } if (i * Constants.SingleLineHeight < this.scrollbar.Offset) { this.scrollbar.Offset = i * Constants.SingleLineHeight; } else if ((i + 1) * Constants.SingleLineHeight - this.scrollbar.Offset > this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + (i + 1) * Constants.SingleLineHeight; } this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } } } else { for (int i = 0; i < this.displayingTypes.Count; i++) { if (this.displayingTypes[i] == this.SelectedType) { if (i == 0) { GUI.FocusControl(GenericTypesSelectorWizard.TextControlName); this.SelectedType = null; } else { i = Mathf.Max(0, i - shift); this.SelectedType = this.displayingTypes[i]; } if (i * Constants.SingleLineHeight < this.scrollbar.Offset) { this.scrollbar.Offset = i * Constants.SingleLineHeight; } else if ((i + 1) * Constants.SingleLineHeight - this.scrollbar.Offset > this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + (i + 1) * Constants.SingleLineHeight; } this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } } } } else if (Event.current.keyCode == KeyCode.PageDown || Event.current.keyCode == KeyCode.DownArrow) { int shift = Event.current.keyCode == KeyCode.PageDown ? (int)((this.position.height - Constants.SingleLineHeight) / Constants.SingleLineHeight) : 1; GUI.FocusControl(null); if (this.EnableCategories == true) { if (this.SelectedType == null) { this.scrollbar.Offset = 0F; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); foreach (var pair in this.categories) { for (int i = 0; i < pair.Value.Count;) { this.SelectedType = pair.Value[i]; return; } } } float shiftOffset = Event.current.keyCode == KeyCode.PageDown ? this.position.height - Constants.SingleLineHeight - Constants.SingleLineHeight : 0F; float offset = 0F; float startOffset = -1F; float lastHeight = 0F; Type lastType = null; foreach (var pair in this.categories) { offset += GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; for (int i = 0; i < pair.Value.Count; i++) { offset += Constants.SingleLineHeight; lastType = pair.Value[i]; if (startOffset > 0F && offset - startOffset > shiftOffset) { if (i == 0) { lastHeight += GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; } lastHeight += Constants.SingleLineHeight; lastType = pair.Value[i]; goto doubleBreak; } if (pair.Value[i] == this.SelectedType) { startOffset = offset; } } } doubleBreak: if (this.SelectedType != lastType) { this.SelectedType = lastType; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); } if (offset - lastHeight < this.scrollbar.Offset) { this.scrollbar.Offset = offset - lastHeight; } else if (offset > this.scrollbar.Offset + this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + offset; } this.Repaint(); return; } else if (string.IsNullOrEmpty(this.filter) == true) { if (this.SelectedType == null && this.types.Length > 0) { this.scrollbar.Offset = 0F; this.SelectedType = this.types[0]; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } for (int i = 0; i < this.types.Length; i++) { if (this.types[i] == this.SelectedType) { i = Mathf.Min(i + shift, this.types.Length - 1); if (i * Constants.SingleLineHeight < this.scrollbar.Offset) { this.scrollbar.Offset = i * Constants.SingleLineHeight; } else if ((i + 1) * Constants.SingleLineHeight - this.scrollbar.Offset > this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + (i + 1) * Constants.SingleLineHeight; } this.SelectedType = this.types[i]; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } } } else { if (this.SelectedType == null && this.displayingTypes.Count > 0) { this.scrollbar.Offset = 0F; this.SelectedType = this.displayingTypes[0]; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } for (int i = 0; i < this.displayingTypes.Count; i++) { if (this.displayingTypes[i] == this.SelectedType) { i = Mathf.Min(i + shift, this.displayingTypes.Count - 1); if (i * Constants.SingleLineHeight < this.scrollbar.Offset) { this.scrollbar.Offset = i * Constants.SingleLineHeight; } else if ((i + 1) * Constants.SingleLineHeight - this.scrollbar.Offset > this.scrollbar.MaxHeight) { this.scrollbar.Offset = -this.scrollbar.MaxHeight + (i + 1) * Constants.SingleLineHeight; } this.SelectedType = this.displayingTypes[i]; this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); this.Repaint(); return; } } } } } GUI.SetNextControlName(GenericTypesSelectorWizard.TextControlName); this.filter = GUILayout.TextField(this.filter, GeneralStyles.ToolbarSearchTextField); if (GUILayout.Button(GUIContent.none, GeneralStyles.ToolbarSearchCancelButton) == true) { this.filter = string.Empty; } } if (EditorGUI.EndChangeCheck() == true) { this.scrollWitnessOnce = false; this.scrollbar.ClearInterests(); if (this.EnableCategories == true) { this.categories.Clear(); this.ProcessMaxNamespaceWidth(this.types); for (int i = 0; i < this.types.Length; i++) { if (CultureInfo.InvariantCulture.CompareInfo.IndexOf(this.types[i].FullName, this.filter, CompareOptions.IgnoreCase) == -1) { continue; } this.AddTypeToCategory(this.types[i]); } } else if (string.IsNullOrEmpty(this.filter) == false) { this.temporaryFilterTypes.Clear(); for (int i = 0; i < this.types.Length; i++) { if (CultureInfo.InvariantCulture.CompareInfo.IndexOf(this.types[i].FullName, this.filter, CompareOptions.IgnoreCase) != -1) { this.temporaryFilterTypes.Add(this.types[i]); } } if (this.temporaryFilterTypes.Count > 0) { List <Type> tmp = this.displayingTypes; this.displayingTypes = this.temporaryFilterTypes; this.temporaryFilterTypes = tmp; // Add a fake value to avoid the input filter turning red. this.temporaryFilterTypes.Add(null); this.ProcessMaxNamespaceWidth(this.displayingTypes); } else { if (this.displayingTypes.Count == 0) { this.displayingTypes.AddRange(this.types); } this.ProcessMaxNamespaceWidth(this.displayingTypes); } } else { this.displayingTypes.Clear(); this.namespaceWidth = this.allNamespaceWidth; this.nameWidth = this.allNameWidth; this.ResizeWindow(); } } EditorGUI.BeginDisabledGroup(this.SelectedType == null && this.EnableNullValue == false); { if (GUILayout.Button(LC.G("Select"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.ExpandWidthFalse) == true) { this.Create(this.SelectedType); } } EditorGUI.EndDisabledGroup(); } GUILayout.EndHorizontal(); Rect r = GUILayoutUtility.GetRect(0F, Constants.SingleLineHeight); float rowHeight = r.height; if (Event.current.type == EventType.Repaint) { float totalHeight = 0F; if (this.EnableNullValue == true) { totalHeight = rowHeight; } if (this.EnableCategories == true) { float categoryHeight = GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; foreach (var pair in this.categories) { totalHeight += categoryHeight + (pair.Value.Count * rowHeight); } } else if (string.IsNullOrEmpty(this.filter) == true) { totalHeight += this.types.Length * rowHeight; } else { totalHeight += this.displayingTypes.Count * rowHeight; } this.scrollbar.RealHeight = totalHeight; this.scrollbar.SetPosition(this.position.width - 15F, r.y); this.scrollbar.SetSize(this.position.height - r.y); } this.scrollbar.OnGUI(); Rect bodyRect = this.position; bodyRect.x = 0F; bodyRect.y = r.y; bodyRect.height -= r.y; GUI.BeginGroup(bodyRect); { r.y = -this.scrollbar.Offset; r.width -= this.scrollbar.MaxWidth; if (this.EnableNullValue == true) { this.DrawType(r, null, string.Empty, "Null"); r.y += r.height; } if (this.EnableCategories == true) { float categoryHeight = GeneralStyles.BigCenterText.lineHeight + GeneralStyles.BigCenterText.padding.vertical; foreach (var pair in this.categories) { r.height = categoryHeight; GUI.Label(r, pair.Key, GeneralStyles.BigCenterText); r.y += r.height; r.height = rowHeight; for (int i = 0; i < pair.Value.Count; i++) { if (this.scrollWitnessOnce == true && r.y + r.height <= 0) { r.y += r.height; continue; } this.DrawType(r, pair.Value[i], pair.Value[i].Namespace, pair.Value[i].Name); r.y += r.height; if (this.scrollWitnessOnce == true && r.y > this.scrollbar.MaxHeight) { break; } } } } else if (string.IsNullOrEmpty(this.filter) == true) { for (int i = 0; i < this.types.Length; i++) { if (this.scrollWitnessOnce == true && r.y + r.height <= 0) { r.y += r.height; continue; } this.DrawType(r, this.types[i], this.types[i].Namespace, this.types[i].Name); r.y += r.height; if (this.scrollWitnessOnce == true && r.y > this.scrollbar.MaxHeight) { break; } } } else { for (int i = 0; i < this.displayingTypes.Count; i++) { if (this.scrollWitnessOnce == true && r.y + r.height <= 0) { r.y += r.height; continue; } this.DrawType(r, this.displayingTypes[i], this.displayingTypes[i].Namespace, this.displayingTypes[i].Name); r.y += r.height; if (this.scrollWitnessOnce == true && r.y > this.scrollbar.MaxHeight) { break; } } } } GUI.EndGroup(); }
private static bool DetectDiff(bool silent) { if (HQ.Settings == null || NGHotkeys.isGenerating == true) { return(false); } CustomHotkeysSettings settings = HQ.Settings.Get <CustomHotkeysSettings>(); bool isDifferent = false; Type type = Utility.GetType("NGToolsEditor", "CustomHotkeys"); if (type != null) { MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static); if (methods.Length != settings.hotkeys.Count) { isDifferent = true; } else { MenuItem[][] attributes = new MenuItem[methods.Length][]; for (int i = 0; i < methods.Length; i++) { attributes[i] = methods[i].GetCustomAttributes(typeof(MenuItem), false) as MenuItem[]; } for (int i = 0; i < settings.hotkeys.Count; i++) { CustomHotkeysSettings.MethodHotkey binding = settings.hotkeys[i]; for (int j = 0; j < NGHotkeys.shortcuts.Count; j++) { MenuItemShortcut shortcut = NGHotkeys.shortcuts[j]; if ([email protected] + '.' + shortcut.staticMethod == binding.staticMethod) { for (int k = 0; k < attributes.Length; k++) { for (int l = 0; l < attributes[k].Length; l++) { string s = Constants.MenuItemPath + NGHotkeys.SubMenuItemPath + shortcut.name + " _"; if (attributes[k][l].menuItem.StartsWith(s) == true) { if (attributes[k][l].menuItem.Substring(s.Length) != binding.bind) { isDifferent = true; goto quadrupleBreaks; } goto doubleBreaks; } } } doubleBreaks: break; } } } } } else if (settings.hotkeys.Count > 0) { isDifferent = true; } quadrupleBreaks: if (isDifferent == true && silent == false) { EditorApplication.delayCall += () => { if (EditorUtility.DisplayDialog(NGHotkeys.Title, "The current hotkeys bindings do not match your settings.\nThis might happen after an update of NG Tools.\n\nDo you want to restore your setup?", LC.G("Yes"), LC.G("No")) == true) { NGHotkeys.isGenerating = true; NGHotkeys.Generate(); HQ.InvalidateSettings(HQ.Settings, true); } }; } return(isDifferent); }
protected virtual void OnGUI() { GUILayout.Label(Constants.PackageTitle, GeneralStyles.MainTitle); GUILayout.Label("Version " + Constants.Version); GUILayout.FlexibleSpace(); Rect r = GUILayoutUtility.GetRect(this.position.width, 150F); r.width = r.width * .5F - 5F; r.height = r.height * .33F - 5F; r.x += 3.33F; r.y += 5F; if (GUI.Button(r, Preferences.DiscordContent, GeneralStyles.BigButton) == true) { Application.OpenURL(Constants.DiscordURL); } r.y += r.height + 5F; if (GUI.Button(r, Preferences.TwitterContent, GeneralStyles.BigButton) == true) { Application.OpenURL(Constants.TwitterURL); } r.y += r.height + 5F; if (GUI.Button(r, Preferences.UnityForumContent, GeneralStyles.BigButton) == true) { Application.OpenURL(Constants.SupportForumUnityThread); } r.x += r.width + 3.33F; if (GUI.Button(r, LC.G("Preferences_Contact"), GeneralStyles.BigButton) == true) { ContactFormWizard.Open(ContactFormWizard.Subject.Contact); } r.y -= r.height + 5F; if (GUI.Button(r, "Bit Bucket", GeneralStyles.BigButton) == true) { Application.OpenURL(Constants.TicketURL); } r.y -= r.height + 5F; if (GUI.Button(r, "Documentation", GeneralStyles.BigButton) == true) { Application.OpenURL(Constants.WikiBaseURL); } r.height = 20F; r.y -= r.height + 5F; r.xMin -= 50F; if (GUI.Button(r, "Help with a review!") == true) { List <HQ.ToolAssemblyInfo> licensedTools = new List <HQ.ToolAssemblyInfo>(); foreach (HQ.ToolAssemblyInfo tool in HQ.EachTool) { if (NGLicensesManager.IsLicenseValid(tool.name) == true) { licensedTools.Add(tool); } } if (licensedTools.Count == 0) { if (NGLicensesManager.IsPro() == true) { Application.OpenURL(Constants.AssetStoreNGToolsProURL); } else { Application.OpenURL(Constants.AssetStoreNGToolsFreeURL); } } else { licensedTools.Insert(0, new HQ.ToolAssemblyInfo() { name = "NG Tools Free", assetStoreBuyLink = Constants.AssetStoreNGToolsFreeURL }); PopupWindow.Show(r, new PreviewVersionsBackupPopup(licensedTools)); } } r.y -= r.height + 5F; r.xMin = 220F; if (GUI.Button(r, "Change Log") == true) { Application.OpenURL(Constants.ChangeLogURL); } }
protected virtual void OnGUI() { GUILayout.Label(@"In order to get full power from NG Tools, you need to activate licenses to remove limitations. An ""NG Tools Pro"" license will remove all limitations. Any other license will grant full power to only the tool that it is related."); GUILayout.Space(15F); GUILayout.Label("1. Get the invoice.", GeneralStyles.Title1); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Go to your Order History in the Asset Store."); if (GUILayout.Button("Go to Asset Store orders") == true) { Help.BrowseURL("https://assetstore.unity.com/orders"); } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Label("Top-right corner picture in the Asset Store, then \"<b>My Orders</b>\".", GeneralStyles.RichLabel); GUILayout.Space(10F); GUILayout.Label("Find your purchase line, then look for column \"<b>Invoice Number</b>\".", GeneralStyles.RichLabel); GUILayout.Label(@"It might be empty, Unity can require time to generate it. If it is not appearing, please contact them directly."); GUILayout.Space(10F); GUILayout.Label("If you urgently need the license to work, contact me through the following medium:"); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button(Preferences.DiscordContent, GeneralStyles.BigButton, GUILayoutOptionPool.Height(40F)) == true) { Application.OpenURL(Constants.DiscordURL); } if (GUILayout.Button(Preferences.UnityForumContent, GeneralStyles.BigButton, GUILayoutOptionPool.Height(40F)) == true) { Application.OpenURL(Constants.SupportForumUnityThread); } if (GUILayout.Button(LC.G("Preferences_Contact"), GeneralStyles.BigButton, GUILayoutOptionPool.Height(40F)) == true) { ContactFormWizard.Open(ContactFormWizard.Subject.Contact); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(10F); GUILayout.Label("2. Check invoice.", GeneralStyles.Title1); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Go back to Preferences > NG Tools > Licenses."); if (GUILayout.Button("Go") == true) { Utility.ShowPreferencesWindowAt(Constants.PackageTitle, "Licenses"); Preferences.tab = Preferences.Tab.Licenses; } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Write your invoice in the input at the bottom and add it."); if (GUILayout.Button("Highlight") == true) { Utility.ShowPreferencesWindowAt(Constants.PackageTitle, "Licenses"); Preferences.tab = Preferences.Tab.Licenses; XGUIHighlightManager.Highlight(Preferences.Title + ".AddInvoice"); } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(@"Then you need to check it, to ensure NG Tools recognizes it as a valid license."); if (GUILayout.Button("Highlight") == true) { Utility.ShowPreferencesWindowAt(Constants.PackageTitle, "Licenses"); Preferences.tab = Preferences.Tab.Licenses; bool hasUncheckedLicense = false; foreach (License i in NGLicenses.NGLicensesManager.EachInvoices()) { if (i.status == Status.Unknown) { hasUncheckedLicense = true; break; } } if (hasUncheckedLicense == true) { XGUIHighlightManager.Highlight(Preferences.Title + ".CheckLicense"); } else { EditorUtility.DisplayDialog(Constants.PackageTitle, "You must first add invoice prior to check it.", "OK"); } } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10F); GUILayout.Label("3. Activate license.", GeneralStyles.Title1); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(@"If the license is valid, its associated asset will be displayed. Otherwise, it will show ""Invalid"" in grey letters. Now you can activate it."); if (GUILayout.Button("Highlight") == true) { Utility.ShowPreferencesWindowAt(Constants.PackageTitle, "Licenses"); Preferences.tab = Preferences.Tab.Licenses; bool hasValidLicense = false; foreach (License i in NGLicenses.NGLicensesManager.EachInvoices()) { if (i.status == Status.Valid) { hasValidLicense = true; break; } } if (hasValidLicense == true) { XGUIHighlightManager.Highlight(Preferences.Title + ".ActivateLicense"); } else { EditorUtility.DisplayDialog(Constants.PackageTitle, "You must first check an invoice prior to validate it.", "OK"); } } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10F); GUILayout.Label("4. Manage seats.", GeneralStyles.Title1); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(@"You can verifiy seats associated with your licenses. And revoke them as it fits you."); if (GUILayout.Button("Highlight") == true) { Utility.ShowPreferencesWindowAt(Constants.PackageTitle, "Licenses"); Preferences.tab = Preferences.Tab.Licenses; bool hasValidLicense = false; foreach (License i in NGLicenses.NGLicensesManager.EachInvoices()) { if (i.status == Status.Valid) { hasValidLicense = true; break; } } if (hasValidLicense == true) { XGUIHighlightManager.Highlight(Preferences.Title + ".CheckSeats"); } else { EditorUtility.DisplayDialog(Constants.PackageTitle, "You must first check an invoice prior to manage its seats.", "OK"); } } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(@"If you are encountering issues with seats, please contact me directly. If you require a license without the 2 seats limitation, please contact me directly."); if (GUILayout.Button(LC.G("Preferences_Contact"), GUILayoutOptionPool.ExpandHeightTrue) == true) { ContactFormWizard.Open(ContactFormWizard.Subject.Contact); } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); GUILayout.Space(5F); EditorGUILayout.HelpBox("A license is an invoice.", MessageType.Info); EditorGUILayout.HelpBox("You can activate a license on 2 seats maximum! \"2 seats\" means 2 computers, implying many projects on those 2 computers, as much as you want.", MessageType.Info); if (this.preferencesWindow != null) { this.preferencesWindow.Repaint(); } }
public void OnGUI() { if (HQ.Settings == null) { this.so = null; GUILayout.Label(LC.G("ConsoleSettings_NullTarget")); return; } try { if (this.so == null || this.so.targetObject == null || this.so.targetObject != HQ.Settings.Get(this.typeSetting) as ScriptableObject) { this.so = new SerializedObject(HQ.Settings.Get(this.typeSetting) as ScriptableObject); } else { this.so.Update(); } } catch (Exception ex) { InternalNGDebug.LogException("Setting " + this.typeSetting + " is failing. (" + HQ.Settings.Get(this.typeSetting) + ")", ex); return; } GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Reset", GUILayoutOptionPool.ExpandWidthFalse) == true && ((Event.current.modifiers & Constants.ByPassPromptModifier) != 0 || EditorUtility.DisplayDialog(NGSettingsWindow.Title, LC.G("ConsoleSettings_ResetConfirm"), LC.G("Yes"), LC.G("No")) == true)) { if (this.typeSetting.IsSubclassOf(typeof(ScriptableObject)) == true) { this.so = null; // Delete the current settings. HQ.Settings.Clear(this.typeSetting); // Then regenerate it to ensure it exists and is called from OnGUI context. HQ.Settings.Get(this.typeSetting); } else { object settings = Activator.CreateInstance(this.fieldInfo.FieldType); this.fieldInfo.SetValue(HQ.Settings, settings); } HQ.InvalidateSettings(); InternalEditorUtility.RepaintAllViews(); return; } } GUILayout.EndHorizontal(); if (this.typeSetting.IsSubclassOf(typeof(ScriptableObject)) == true) { SerializedProperty iterator = this.so.GetIterator(); iterator.NextVisible(true); EditorGUI.BeginChangeCheck(); while (iterator.NextVisible(false) == true) { EditorGUILayout.PropertyField(iterator, true); } if (EditorGUI.EndChangeCheck() == true) { this.so.ApplyModifiedProperties(); HQ.InvalidateSettings(); } } else { SerializedProperty iterator = this.so.FindProperty(this.fieldInfo.Name); SerializedProperty end = iterator.GetEndProperty(); bool enterChildren = true; EditorGUI.BeginChangeCheck(); while (iterator.NextVisible(enterChildren) == true && SerializedProperty.EqualContents(iterator, end) == false) { EditorGUILayout.PropertyField(iterator, true); enterChildren = false; } if (EditorGUI.EndChangeCheck() == true) { this.so.ApplyModifiedProperties(); HQ.InvalidateSettings(); } } }