예제 #1
0
 public void SetContentType(InputField.ContentType type)
 {
     if (this.Target == null)
     {
         this.Target = base.GetComponent <InputField>();
     }
     this.Target.set_contentType(type);
 }
예제 #2
0
        public GameObject CreateDoubleButtonInputDialog(string title = "", string inputHint = "", string inputPlaceHolder = "", string inputContent = "",
                                                        InputField.ContentType contentType = InputField.ContentType.Standard, UnityEngine.Events.UnityAction <string> confirmCallback = null, UnityEngine.Events.UnityAction cancelCallback = null)
        {
            GameObject go = UIManager.GetInstance().GetSingleUI(EUIType.DoubleButtonInputDialog);

            go.GetComponent <DoubleButtonInputDialog>().Show(title, inputHint, inputPlaceHolder, inputContent, contentType, confirmCallback, cancelCallback);
            return(go);
        }
예제 #3
0
 private void InternalShow(string prompt, InputField.ContentType contentType)
 {
     gameObject.SetActive(true);
     promptText.text = prompt;
     inputField.text = "";
     inputField.ActivateInputField();
     inputField.contentType = contentType;
     resolved = false;
 }
예제 #4
0
    public GameObject SpawnInputField(string value, InputField.ContentType type)
    {
        GameObject g = SpawnPrefabUI("InputField");
        var        t = g.GetComponent <InputField>();

        t.text        = value;
        t.contentType = type;

        return(g);
    }
        public void SettingLineTypeDoesNotChangesContentTypeToCustom([Values(InputField.ContentType.Standard, InputField.ContentType.Autocorrected)] InputField.ContentType type)
        {
            InputField inputField = m_PrefabRoot.GetComponentInChildren <InputField>();

            inputField.contentType = type;

            inputField.lineType = InputField.LineType.MultiLineNewline;

            Assert.AreEqual(type, inputField.contentType);
        }
    public void Show(string title, string message, Action <string> onClickOk, InputField.ContentType type)
    {
        this.title.text     = title;
        this.message.text   = message;
        this.onClickOk      = onClickOk;
        inField.contentType = (TMP_InputField.ContentType)type;

        canvas.blocksRaycasts = true;
        canvas.alpha          = 1;
    }
예제 #7
0
 public void Show(string title,
                  string description,
                  System.Action <string> onConfirmText,
                  string defaultText = "")
 {
     Title              = title;
     Description        = description;
     InputFieldText     = defaultText;
     contentType        = InputField.ContentType.Standard;
     this.onConfirmText = onConfirmText;
     Show();
 }
예제 #8
0
            /// <summary>
            /// Creates a DialogueObject of type TextInput. Allows the player to input text into the conversation.
            /// </summary>
            /// <param name="name">Name of the person speaking</param>
            /// <param name="line">Dialogue the person says</param>
            /// <param name="contentType">Type of input to be entered into the text input field.</param>
            /// <param name="placeholderText">Text to be displayed in the input field before the player enters text</param>
            /// <param name="maxLength">Max length of the string to be entered. 0 = no max length.</param>
            /// <param name="enterInput">Function to be called when player advances dialogue. Function must be of type void and take in one string variable.</param>
            public DialogueObject(string name, string line, InputField.ContentType contentType, string placeholderText, int maxLength,
                                  EnterInput enterInput)
            {
                dialogueType = DialogueType.TextInput;

                speakerName           = name;
                dialogueLine          = line;
                inputContentType      = contentType;
                inputPlaceholderText  = placeholderText;
                maxInputLength        = maxLength;
                dialogueInputCallback = enterInput;
            }
예제 #9
0
        public GameObject CreateInputFieldWidget(
            GameObject parent        = null,
            IConvertible text        = null,
            IConvertible postfixText = null,
            EditorWidgetFormattingOptions formattingOptions = EditorWidgetFormattingOptions.None,
            InputField.ContentType contentType = InputField.ContentType.Standard,
            UnityEngine.Events.UnityAction <string> onEndEdit = null,
            UnityEngine.Events.UnityAction <string, InputField> newOnEndEdit = null,
            ContainerConfig configOverride = ContainerConfig.Submissive,
            int index = -1,
            int slots = -1)
        {
            GameObject inputFieldWidget = GameObject.Instantiate(optionInputFieldPrefab);

            //Attach to parent and load up appropriate configurations
            CoupleToParent(
                widget: inputFieldWidget,
                parent: parent,
                index: index,
                slots: slots,
                config: configOverride);

            ApplyInputFieldFormattingOptions(inputFieldWidget, formattingOptions);

            if (text == null)
            {
                text = "";
            }

            if (postfixText == null)
            {
                postfixText = "";
            }

            InputField inputField = inputFieldWidget.GetComponent <InputField>();

            inputField.text        = text.ToString();
            inputField.contentType = contentType;

            if (onEndEdit != null)
            {
                inputField.onEndEdit.AddListener(onEndEdit);
            }

            if (newOnEndEdit != null)
            {
                inputField.onEndEdit.AddListener((string value) => { newOnEndEdit.Invoke(value, inputField); });
            }

            inputFieldWidget.GetComponent <OptionInputField>().PostfixText.text = postfixText.ToString();

            return(inputFieldWidget);
        }
예제 #10
0
        /// <summary>
        /// Shows a prompt for the user to enter a string with an option to cancel.
        /// </summary>
        /// <param name="contentValidator">A condition that has to be true before the user is allowed to submit.</param>
        public static DialogStringInput Show(string message, Action <string> submitCallback, Action cancelCallback,
                                             Predicate <string> contentValidator, InputField.ContentType contentType)
        {
            if (contentValidator == null)
            {
                throw new ArgumentException("Content validator can't be null!", nameof(contentValidator));
            }

            var dialog = Show(message, submitCallback, cancelCallback, contentType);

            dialog.SetValidator(contentValidator);
            return(dialog);
        }
예제 #11
0
        /// <summary>
        /// Shows a prompt for the user to enter a string.
        /// </summary>
        /// <param name="cancelCallback">The function to be called when the user hits Cancel. Leave null if nothing should happen.</param>
        public static DialogStringInput Show(string message, Action <string> submitCallback, Action cancelCallback,
                                             InputField.ContentType contentType)
        {
            if (!Enum.IsDefined(typeof(InputField.ContentType), contentType))
            {
                throw new ArgumentException("Contenty type argument has to be a valid InputField.ContentType!", nameof(contentType));
            }

            var dialog = Show(message, submitCallback, cancelCallback);

            dialog.SetContentType(contentType);
            return(dialog);
        }
예제 #12
0
 public void Show(string title,
                  string content,
                  UnityAction <string> onConfirmText,
                  string defaultText = "",
                  InputField.ContentType contentType = InputField.ContentType.Standard,
                  int characterLimit = 0)
 {
     Title               = title;
     Content             = content;
     InputContent        = defaultText;
     this.contentType    = contentType;
     this.characterLimit = characterLimit;
     this.onConfirmText  = onConfirmText;
     Show();
 }
예제 #13
0
 private void SetFieldCount(int count, InputField.ContentType contentType)
 {
     fieldValues = new string[count];
     for (int i = 0; i < fieldArray.Length; i++)
     {
         var fieldItem = fieldArray[i];
         if (i < count)
         {
             fieldItem.gameObject.SetActive(true);
             fieldItem.contentType = contentType;
         }
         else
         {
             fieldItem.gameObject.SetActive(false);
         }
     }
 }
예제 #14
0
    private static int set_contentType(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            InputField             inputField  = (InputField)obj;
            InputField.ContentType contentType = (InputField.ContentType)((int)ToLua.CheckObject(L, 2, typeof(InputField.ContentType)));
            inputField.contentType = contentType;
            result = 0;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index contentType on a nil value");
        }
        return(result);
    }
예제 #15
0
    private static int get_contentType(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            InputField             inputField  = (InputField)obj;
            InputField.ContentType contentType = inputField.contentType;
            ToLua.Push(L, contentType);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.Message : "attempt to index contentType on a nil value");
        }
        return(result);
    }
예제 #16
0
        private string GetCharTypeText(InputField _input_field)
        {
            string separatorString = this.SEPARATOR_STRING;

            InputField.ContentType contentType = _input_field.get_contentType();
            switch (contentType - 2)
            {
            case 0:
                return(separatorString + LocalizedText.Get("sys.CHAR_TYPE_RESTRICTED_FORMAT_NUMBER"));

            case 2:
                return(separatorString + LocalizedText.Get("sys.CHAR_TYPE_RESTRICTED_FORMAT_ALPHANUMERIC"));

            default:
                if (contentType == 9)
                {
                    return(this.GetCharTypeTextByTypeCustom(_input_field));
                }
                return(string.Empty);
            }
        }
        private static TMP_InputField.ContentType GetTMPContentType(InputField.ContentType type)
        {
            switch (type)
            {
            case InputField.ContentType.Alphanumeric:
                return(TMP_InputField.ContentType.Alphanumeric);

            case InputField.ContentType.Autocorrected:
                return(TMP_InputField.ContentType.Autocorrected);

            case InputField.ContentType.Custom:
                return(TMP_InputField.ContentType.Custom);

            case InputField.ContentType.DecimalNumber:
                return(TMP_InputField.ContentType.DecimalNumber);

            case InputField.ContentType.EmailAddress:
                return(TMP_InputField.ContentType.EmailAddress);

            case InputField.ContentType.IntegerNumber:
                return(TMP_InputField.ContentType.IntegerNumber);

            case InputField.ContentType.Name:
                return(TMP_InputField.ContentType.Name);

            case InputField.ContentType.Password:
                return(TMP_InputField.ContentType.Password);

            case InputField.ContentType.Pin:
                return(TMP_InputField.ContentType.Pin);

            case InputField.ContentType.Standard:
                return(TMP_InputField.ContentType.Standard);

            default:
                return(TMP_InputField.ContentType.Standard);
            }
        }
예제 #18
0
    public void Show(string title,
                     string content,
                     UnityAction <int> onConfirmInteger,
                     int?minAmount     = null,
                     int?maxAmount     = null,
                     int defaultAmount = 0)
    {
        if (!minAmount.HasValue)
        {
            minAmount = int.MinValue;
        }
        if (!maxAmount.HasValue)
        {
            maxAmount = int.MaxValue;
        }

        intDefaultAmount = defaultAmount;
        intMinAmount     = minAmount;
        intMaxAmount     = maxAmount;

        Title        = title;
        Content      = content;
        InputContent = defaultAmount.ToString();
        if (inputContent != null)
        {
            if (minAmount.Value > maxAmount.Value)
            {
                minAmount = null;
                Debug.LogWarning("min amount is more than max amount");
            }
            inputContent.onValueChanged.RemoveAllListeners();
            inputContent.onValueChanged.AddListener(ValidateIntAmount);
        }
        contentType           = InputField.ContentType.IntegerNumber;
        characterLimit        = 0;
        this.onConfirmInteger = onConfirmInteger;
        Show();
    }
예제 #19
0
    public void Show(string title,
                     string description,
                     System.Action <int> onConfirmInteger,
                     int?minAmount     = null,
                     int?maxAmount     = null,
                     int defaultAmount = 0)
    {
        if (!minAmount.HasValue)
        {
            minAmount = int.MinValue;
        }
        if (!maxAmount.HasValue)
        {
            maxAmount = int.MaxValue;
        }

        intDefaultAmount = defaultAmount;
        intMinAmount     = minAmount;
        intMaxAmount     = maxAmount;

        Title          = title;
        Description    = description;
        InputFieldText = defaultAmount.ToString();
        if (uiInputField != null)
        {
            if (minAmount.Value > maxAmount.Value)
            {
                minAmount = null;
                Debug.LogWarning("min amount is more than max amount");
            }
            uiInputField.onValueChanged.RemoveAllListeners();
            uiInputField.onValueChanged.AddListener(ValidateIntAmount);
        }
        contentType           = InputField.ContentType.IntegerNumber;
        this.onConfirmInteger = onConfirmInteger;
        Show();
    }
예제 #20
0
    public void Show(string title,
                     string description,
                     System.Action <float> onConfirmDecimal,
                     float?minAmount     = null,
                     float?maxAmount     = null,
                     float defaultAmount = 0f)
    {
        if (!minAmount.HasValue)
        {
            minAmount = float.MinValue;
        }
        if (!maxAmount.HasValue)
        {
            maxAmount = float.MaxValue;
        }

        floatDefaultAmount = defaultAmount;
        floatMinAmount     = minAmount;
        floatMaxAmount     = maxAmount;
        Title          = title;
        Description    = description;
        InputFieldText = defaultAmount.ToString();
        if (uiInputField != null)
        {
            if (minAmount.Value > maxAmount.Value)
            {
                minAmount = null;
                Debug.LogWarning("min amount is more than max amount");
            }
            uiInputField.onValueChanged.RemoveAllListeners();
            uiInputField.onValueChanged.AddListener(ValidateFloatAmount);
        }
        contentType           = InputField.ContentType.DecimalNumber;
        this.onConfirmDecimal = onConfirmDecimal;
        Show();
    }
        public void Show(string title, string inputHint, string inputPlaceHolder, string inputContent, InputField.ContentType contentType,
                         UnityEngine.Events.UnityAction <string> confirmCallback, UnityEngine.Events.UnityAction cancelCallback)
        {
            gameObject.SetActive(true);
            UIManager.GetInstance().SetSiblingToTop(gameObject);

            if (title != null)
            {
                _labelTitle.text = title;
            }

            if (inputHint != null)
            {
                _labelInputHint.text = inputHint;
            }

            if (inputPlaceHolder != null)
            {
                _inputContent.placeholder.GetComponent <Text>().text = inputPlaceHolder;
            }

            if (inputContent != null)
            {
                _inputContent.text = inputContent;
            }

            _inputContent.contentType = contentType;

            _confirmCallback = confirmCallback;
            _buttonConfirm.onClick.AddListener(OnClickConfirmButton);


            if (cancelCallback != null)
            {
                _buttonCancel.onClick.AddListener(cancelCallback);
            }
            _buttonCancel.onClick.AddListener(Hide);

            BeginEnterTween();
        }
예제 #22
0
 public static void Show(string prompt, InputField.ContentType contentType)
 {
     GetInstance().InternalShow(prompt, contentType);
 }
예제 #23
0
 public void SetContentType(InputField.ContentType contentType)
 {
     _input.contentType = contentType;
 }
예제 #24
0
 public void SetValueInputType(InputField.ContentType contentType)
 {
     Value.contentType = contentType;
 }
예제 #25
0
 public void SetInputType(InputField.ContentType inputType)
 {
     GetComponent <InputField>().contentType = inputType;
 }
예제 #26
0
    /// <summary>
    /// Displays this screen.
    /// </summary>
    /// <param name="infoText">The text that should be displayed in the screen.</param>
    /// <param name="minTextLength">The lowest acceptable letter-count in input.</param>
    /// <param name="maxTextLength">The maximum acceptable letter-count in input.</param>
    /// <param name="allowCancel">Whether to allow cancelling or not.</param>
    /// <param name="callbackConfirm">Callback for what happens when confirming.</param>
    /// <param name="keyboardType">The type of keyboard to be displayed when inputting. Should preferably match the content type.</param>
    /// <param name="startValue">Start text value.</param>
    /// <param name="inputType">The input type.</param>
    /// <param name="lineType">The line type.</param>
    public virtual void Set(string infoText, int minTextLength, int maxTextLength, bool allowCancel, System.Action <string> callbackConfirm = null, TouchScreenKeyboardType keyboardType = TouchScreenKeyboardType.Default, string startValue = "", InputField.LineType lineType = InputField.LineType.MultiLineSubmit, InputField.ContentType contentType = InputField.ContentType.Standard, string promptText = "Enter Text")
    {
        this.displayText.text        = infoText;
        this.startValue              = startValue;
        this.minTextLength           = minTextLength;
        this.maxTextLength           = maxTextLength;
        this.defaultErrorDisplayText = "Must be between " + minTextLength.ToString() + " and " + maxTextLength.ToString() + " characters long";

        this.input.onValueChanged.AddListener(delegate { OnInputChange(); });
        this.input.keyboardType   = keyboardType;
        this.input.colors         = GetColorBlock();
        this.input.contentType    = contentType;
        this.input.lineType       = lineType;
        this.input.characterLimit = maxTextLength;
        this.input.SetTextWithoutNotify(startValue);
        this.input.placeholder.GetComponent <Text>().text = promptText;
        this.input.Select();
        OnInputChange(); // Makes sure buttons and requirements text is properly enabled/disabled.

        this.cancelButton.gameObject.SetActive(allowCancel);

        this.callbackConfirm = callbackConfirm;
    }
예제 #27
0
 public InputFieldModel(Type[] types, TouchScreenKeyboardType keyboardType, InputField.ContentType contentType)
 {
     this.types        = new List <Type>(types);
     this.keyboardType = keyboardType;
     this.contentType  = contentType;
 }
예제 #28
0
 public void SetContentType(InputField.ContentType contentType)
 {
     _cachedView.ContentInputField.contentType = contentType;
 }
예제 #29
0
 public void SetTextType(InputField.ContentType type)
 {
     GetComponentInChildren <InputField>().contentType = type;
 }
예제 #30
0
    public static Keyboard Show(string title, string defaultText = "", int maxLength     = 0,
                                Action <string> onSubmit         = null, Action onCancel = null, InputField.ContentType type = InputField.ContentType.Standard)
    {
        var kbd = Instantiate(Resources.Load <GameObject>("Keyboard")).GetComponent <Keyboard>();

        kbd.onSubmit = onSubmit;
        kbd.onCancel = onCancel;

        kbd.Title.text                = title;
        kbd.InputField.text           = defaultText;
        kbd.InputField.contentType    = type;
        kbd.InputField.characterLimit = maxLength;

        return(kbd);
    }