/// <summary> /// Show the modal dialog in the indicated mode, and call the callback when it receives a response /// </summary> public static void ShowInputModal( Mode mode, string headerText, string bodyText, ModalInputCallback inputCallback, ModalButtonCallback buttonCallback = null) { Debug.Assert( condition: mode == Mode.InputAccept || mode == Mode.InputConfirmCancel, message: "Incorrect method call. Don't call ShowInputModal if not using input."); //Update text instance.SetHeaderText(headerText); instance.SetBodyText(bodyText); //Update buttons instance.SetMode(mode); //Set dialog visible instance.gameObject.SetActive(true); //Update callbacks instance.buttonCallback = buttonCallback; instance.inputCallback = inputCallback; instance.doubleInputCallback = null; }
/// <summary> /// Show the modal dialog in the indicated mode, and call the callback when it receives a response /// </summary> public static void ShowInputModalABC( string headerText, string bodyText, string buttonALabel, string buttonBLabel, string buttonCLabel, ModalInputCallback inputCallback, ModalButtonCallback buttonCallback = null, InputField.ContentType inputType = InputField.ContentType.Alphanumeric) { //Update text instance.SetHeaderText(headerText); instance.SetBodyText(bodyText); //Update buttons instance.SetMode(Mode.InputABC); instance.SetButtonText(buttonALabel, buttonBLabel, buttonCLabel); //Set dialog visible instance.gameObject.SetActive(true); //Update callbacks instance.buttonCallback = buttonCallback; instance.inputCallback = inputCallback; instance.inputToggleCallback = 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; ModalDoubleInputCallback tmpDoubleInputCallback = doubleInputCallback; buttonCallback = null; inputCallback = null; doubleInputCallback = null; gameObject.SetActive(false); tmpCallback?.Invoke(response); tmpInputCallback?.Invoke(response, primaryInputField.text); tmpDoubleInputCallback?.Invoke(response, primaryInputField.text, secondaryInputField.text); }