public virtual void OnEnable()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                if (trs == null)
                {
                    trs = GetComponent <Transform>();
                }
                keys = GetComponentsInChildren <VirtualKey>();
                return;
            }
#endif
            Menus.Instance.enabled = false;
            if (outputToInputField != null)
            {
                OutputPosition          = 0;
                outputToInputField.text = "";
                if (!initialized)
                {
                    outputToInputField.GetType().GetField("m_AllowInput", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(outputToInputField, true);
                    outputToInputField.GetType().InvokeMember("SetCaretVisible", BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance, null, outputToInputField, null);
                    Transform outputToInputFieldTrs = outputToInputField.GetComponent <Transform>();
                    outputToInputFieldTrs.SetParent(outputToInputFieldTrs.root);
                    initialized = true;
                }
                else
                {
                    outputToInputField.GetComponent <CanvasGroup>().alpha = 1;
                }
            }
            GameManager.singletons.Remove(GetType());
            GameManager.singletons.Add(GetType(), this);
        }
Beispiel #2
0
    /// <summary>
    /// turns input filed caret always on.
    /// Code source: https://forum.unity.com/threads/howto-inputfield-always-show-caret.424556/
    /// </summary>
    /// <param name="pos">Caret position.</param>
    public void SetCarretVisible(int pos)
    {
        InputField inputField = gameObject.GetComponent <InputField>();

        inputField.caretPosition = pos; // desired cursor position

        inputField.GetType().GetField("m_AllowInput", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(inputField, true);
        inputField.GetType().InvokeMember("SetCaretVisible", BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance, null, inputField, null);
    }
Beispiel #3
0
 void MostrarCursor()
 {
     if (txtTexto.isActiveAndEnabled)
     {
         txtTexto.caretPosition = Posicion;
         txtTexto.GetType().GetField("m_AllowInput", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(txtTexto, true);
         txtTexto.GetType().InvokeMember("SetCaretVisible", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, null, txtTexto, null);
     }
 }
    void Start()
    {
        inputField.caretPosition = 0; // desired cursor position

        inputField.GetType().GetField("m_AllowInput", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(inputField, true);
        inputField.GetType().InvokeMember("SetCaretVisible", BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance, null, inputField, null);

        acceptButton.onClick.AddListener(() => OnAccepted?.Invoke(inputField.text));
        cancelButton.onClick.AddListener(() => OnCancelled?.Invoke());
    }
 public virtual void Init()
 {
     outputToInputField.GetType().GetField("m_AllowInput", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(outputToInputField, true);
     outputToInputField.GetType().InvokeMember("SetCaretVisible", BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance, null, outputToInputField, null);
 }
Beispiel #6
0
        public List <string> FindWidgetTypes()
        {
            List <string> types = new List <string>();

#if NGUI
            UIRect[] rectArr = this.gameObject.GetComponents <UIRect>();
            foreach (UIRect rect in rectArr)
            {
                types.Add(rect.GetType().FullName);
            }

            UIWidgetContainer[] container = this.gameObject.GetComponents <UIWidgetContainer>();
            foreach (UIWidgetContainer widget in container)
            {
                types.Add(widget.GetType().FullName);
            }

            UIInput input = this.gameObject.GetComponent <UIInput>();
            if (input)
            {
                types.Add(input.GetType().FullName);
            }

            UIWrapContent wrap = this.gameObject.GetComponent <UIWrapContent>();
            if (wrap)
            {
                types.Add(wrap.GetType().FullName);
            }
#elif UGUI
            Text txt = this.gameObject.GetComponent <Text>();
            if (txt)
            {
                types.Add(txt.GetType().Name);
            }
            Image img = this.gameObject.GetComponent <Image>();
            if (img)
            {
                types.Add(img.GetType().Name);
            }
            Button btn = this.gameObject.GetComponent <Button>();
            if (btn)
            {
                types.Add(btn.GetType().Name);
            }
            InputField inputField = this.gameObject.GetComponent <InputField>();
            if (inputField)
            {
                types.Add(inputField.GetType().Name);
            }
            Toggle tog = this.gameObject.GetComponent <Toggle>();
            if (tog)
            {
                types.Add(tog.GetType().Name);
            }
            Slider slider = this.gameObject.GetComponent <Slider>();
            if (slider)
            {
                types.Add(slider.GetType().Name);
            }
            Scrollbar scrollbar = this.gameObject.GetComponent <Scrollbar>();
            if (scrollbar)
            {
                types.Add(scrollbar.GetType().Name);
            }
            ScrollRect rect = this.gameObject.GetComponent <ScrollRect>();
            if (rect)
            {
                types.Add(rect.GetType().Name);
            }
#endif

            //if (types.Count <= 0)
            {
                types.Add("GameObject");
                types.Add("Transform");
            }

            return(types);
        }