private void OnHideEnd() { log.Debug("{0} HideEnd", name); InputBlocker.Hide(this); eventReg.DeregisterEvents(); try { PostClose(); } catch (Exception e) { log.Error(e); } if (tabs != null) { tabs.CloseAndResetTab(); } PopupCallback callback = closeCallback; this.closeCallback = null; releasables.Release(); if (callback != null) { callback(); } if (onHideEnd != null) { onHideEnd(); } if (!shared) { Object.Destroy(go); } }
private void OnShowEnd() { log.Debug("{0} ShowEnd", name); if (window.buttonHandler != null) { window.buttonHandler.enabled = true; } try { SetLayer(); SetContentsLazy(); } catch (Exception ex) { log.Error(ex); } try { PostOpen(); } catch (Exception e) { log.Error(e); } InputBlocker.Hide(this); if (onShowEnd != null) { onShowEnd(); } loadData.consumed = true; if (openCallback != null) { openCallback(); openCallback = null; } InputBlocker.Hide(this); }
public void SetUpGenericPopup(string title, string description, int minVal, int maxVal, PopupCallback callback) { Header.text = title; DescriptionText.text = description; Slider.minValue = minVal; Slider.maxValue = maxVal; Slider.value = maxVal / 2; Input.text = Mathf.RoundToInt(Slider.value).ToString(); acceptCallback = callback; }
public static bool Popup( Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, object[] list, GUIStyle buttonStyle, GUIStyle boxStyle, GUIStyle listStyle, PopupCallback callback) { int controlID = GUIUtility.GetControlID(popupListHash, FocusType.Passive); bool done = false; switch (Event.current.GetTypeForControl(controlID)) { case EventType.mouseDown: if (position.Contains(Event.current.mousePosition)) { GUIUtility.hotControl = controlID; showList = true; } break; case EventType.mouseUp: if (showList) { done = true; // Call our delegate method callback(); } break; } GUI.Label(position, buttonContent, buttonStyle); if (showList) { // Get our list of strings string[] text = new string[list.Length]; // convert to string for (int i = 0; i < list.Length; i++) { text[i] = list[i].ToString(); } Rect listRect = new Rect(position.x, position.y, position.width, list.Length * 20); GUI.Box(listRect, "", boxStyle); listEntry = GUI.SelectionGrid(listRect, listEntry, text, 1, listStyle); } if (done) { showList = false; } return(done); }
public static bool Popup( Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, object[] list, GUIStyle listStyle, PopupCallback callback) { return(Popup( position, ref showList, ref listEntry, buttonContent, list, "button", "box", listStyle, callback)); }
public static bool Popup( Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, object[] list, GUIStyle buttonStyle, GUIStyle boxStyle, GUIStyle listStyle, PopupCallback callback) { int controlID = GUIUtility.GetControlID(popupListHash, FocusType.Passive); bool done = false; switch (Event.current.GetTypeForControl(controlID)) { case EventType.mouseDown: if (position.Contains(Event.current.mousePosition)) { GUIUtility.hotControl = controlID; showList = true; } break; case EventType.mouseUp: if (showList) { done = true; // Call our delegate method callback(); } break; } GUI.Label(position, buttonContent, buttonStyle); if (showList) { // Get our list of strings string[] text = new string[list.Length]; // convert to string for (int i = 0; i < list.Length; i++) { text[i] = list[i].ToString(); } Rect listRect = new Rect(position.x, position.y, position.width, list.Length * 20); GUI.Box(listRect, "", boxStyle); listEntry = GUI.SelectionGrid(listRect, listEntry, text, 1, listStyle); } if (done) { showList = false; } return done; }
public static bool Popup( Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, object[] list, GUIStyle listStyle, PopupCallback callback) { return Popup( position, ref showList, ref listEntry, buttonContent, list, "button", "box", listStyle, callback); }
public void showConfirm(PopupCallback callback) { GRoot.inst.ShowPopup(popupWindow); popupWindow.GetChild("ok").onClick.Clear(); popupWindow.GetChild("ok").onClick.Add(delegate(EventContext context) { if (callback != null) { callback.Invoke(); } GRoot.inst.HidePopup(popupWindow); }); popupWindow.SetXY(GRoot.inst.width / 2, GRoot.inst.height / 2); }
/// <summary> /// Render an editor popup and return the newly selected option. /// </summary> /// <param name="position">The position of the control.</param> /// <param name="callback">The function called when a value is selected.</param> /// <param name="options">The list of available options.</param> /// <param name="selectedOption">The selected option, or null for none.</param> /// <param name="noneOption">The option for "no selection", or null for none.</param> /// <param name="hasMultipleDifferentValues">Whether the content has multiple different values.</param> /// <param name="allowOuterOption">Whether a selected option not in range should be allowed.</param> public static void Render ( Rect position, PopupCallback callback, IEnumerable <PopupOption <T> > options, PopupOption <T> selectedOption, PopupOption <T> noneOption, bool hasMultipleDifferentValues, bool allowOuterOption = true ) { bool hasOptions = options != null && options.Any(); string label; if (hasMultipleDifferentValues) { label = "\u2014"; // Em Dash } else if (selectedOption == null) { if (noneOption != null) { label = noneOption.label; } else { label = string.Empty; } } else { label = selectedOption.label; } if (GUI.Button(position, label, EditorStyles.popup)) { GenericMenu menu = new GenericMenu(); GenericMenu.MenuFunction2 menuCallback = (o) => callback((T)o); if (noneOption != null) { bool on = !hasMultipleDifferentValues && (selectedOption == null || EqualityComparer <T> .Default.Equals(selectedOption.value, noneOption.value)); menu.AddItem(new GUIContent(noneOption.label), on, menuCallback, noneOption.value); } if (noneOption != null && hasOptions) { menu.AddSeparator(""); } if (hasOptions) { foreach (var option in options) { bool on = !hasMultipleDifferentValues && (selectedOption != null && EqualityComparer <T> .Default.Equals(selectedOption.value, option.value)); menu.AddItem(new GUIContent(option.label), on, menuCallback, option.value); } } Vector2 menuPosition = new Vector2(position.xMin, position.yMax); menu.DropDown(new Rect(menuPosition, Vector2.zero)); } else if (selectedOption != null && !options.Select(o => o.value).Contains(selectedOption.value) && !allowOuterOption) { // Selected option isn't in range if (hasMultipleDifferentValues) { // Do nothing } else if (noneOption != null) { callback(noneOption.value); } else { callback(default(T)); } } }
private void PopupMessage(string message) { PopupCallback?.Invoke(message); }
public void SetUpResourcePopup(string title, string description, ResourceType type, ResourceStorage storage, PopupCallback callback) { SetUpGenericPopup(title, description, 0, storage.CheckResource(type), callback); }
public void ClearCloseCallback() { closeCallback = null; }