/// <summary> /// Show the modal dialog in the indicated mode, and call the callback when it receives a response /// </summary> public static void ShowInputToggleModal( string headerText, string bodyText, string toggleText, ModalInputToggleCallback inputToggleCallback, InputField.ContentType inputType = InputField.ContentType.Alphanumeric, bool initialToggleState = false) { //Update text instance.SetHeaderText(headerText); instance.SetBodyText(bodyText); instance.SetToggleText(toggleText); instance.toggleButton.isOn = initialToggleState; //Update buttons instance.SetMode(Mode.InputToggleConfirmCancel); //Set dialog visible instance.gameObject.SetActive(true); //Update callbacks instance.inputToggleCallback = inputToggleCallback; instance.buttonCallback = null; instance.inputCallback = null; instance.doubleInputCallback = null; instance.dropdownInputCallback = null; instance.primaryInputField.contentType = inputType; }
/// <summary> /// Accept the button repsonse as input, invoke and clear the callbacks, and hide the dialog /// </summary> private void HandleButtons(Response response) { //Temporary copy to allow for the calling of the dialog within a callback ModalButtonCallback tmpCallback = buttonCallback; ModalInputCallback tmpInputCallback = inputCallback; ModalInputToggleCallback tmpInputToggleCallback = inputToggleCallback; ModalDoubleInputCallback tmpDoubleInputCallback = doubleInputCallback; ModalDropdownInputCallback tmpDropdownInputCallback = dropdownInputCallback; buttonCallback = null; inputCallback = null; inputToggleCallback = null; doubleInputCallback = null; dropdownInputCallback = null; gameObject.SetActive(false); tmpCallback?.Invoke(response); tmpInputCallback?.Invoke(response, primaryInputField.text); tmpInputToggleCallback?.Invoke(response, primaryInputField.text, toggleButton.isOn); tmpDoubleInputCallback?.Invoke(response, primaryInputField.text, secondaryInputField.text); tmpDropdownInputCallback?.Invoke(response, optionDropdown.value, secondaryInputField.text); }