Esempio n. 1
0
        public KeyboardUI SpawnAlphaNumericKeyboard()
        {
            if (m_NumericKeyboard != null)
            {
                m_NumericKeyboard.gameObject.SetActive(false);
            }

            // Check if the prefab has already been instantiated
            if (m_StandardKeyboard == null)
            {
                m_StandardKeyboard = ObjectUtils.Instantiate(m_StandardKeyboardPrefab.gameObject, CameraUtils.GetCameraRig()).GetComponent <KeyboardUI>();
            }

            return(m_StandardKeyboard);
        }
Esempio n. 2
0
        KeyboardUI SpawnNumericKeyboard()
        {
            if (m_StandardKeyboard != null)
            {
                m_StandardKeyboard.gameObject.SetActive(false);
            }

            // Check if the prefab has already been instantiated
            if (m_NumericKeyboard == null)
            {
                m_NumericKeyboard = U.Object.Instantiate(m_NumericKeyboardPrefab.gameObject, U.Camera.GetViewerPivot()).GetComponent <KeyboardUI>();
            }

            return(m_NumericKeyboard);
        }
Esempio n. 3
0
        /// <summary>
        /// Open a keyboard for this input field
        /// </summary>
        public virtual void OpenKeyboard()
        {
            if (m_KeyboardOpen)
            {
                return;
            }

            m_KeyboardOpen = true;

            m_Keyboard = spawnKeyboard();

            m_Keyboard.gameObject.SetActive(true);

            this.StopCoroutine(ref m_MoveKeyboardCoroutine);

            var keyboardOutOfRange = (m_Keyboard.transform.position - transform.position).magnitude > 0.25f;

            m_MoveKeyboardCoroutine = StartCoroutine(MoveKeyboardToInputField(keyboardOutOfRange));
        }
Esempio n. 4
0
        public KeyboardUI SpawnAlphaNumericKeyboard()
        {
            if (m_NumericKeyboard != null)
            {
                m_NumericKeyboard.gameObject.SetActive(false);
            }

            // Check if the prefab has already been instantiated
            if (m_StandardKeyboard == null)
            {
                m_StandardKeyboard = ObjectUtils.Instantiate(m_StandardKeyboardPrefab.gameObject, CameraUtils.GetCameraRig(), false).GetComponent <KeyboardUI>();
                var smoothMotions = m_StandardKeyboard.GetComponentsInChildren <SmoothMotion>(true);
                foreach (var smoothMotion in smoothMotions)
                {
                    this.ConnectInterfaces(smoothMotion);
                }
            }

            return(m_StandardKeyboard);
        }
Esempio n. 5
0
    public override void OnInspectorGUI()
    {
        m_KeyboardUI = (KeyboardUI)target;

        var labelWidth = EditorGUIUtility.labelWidth;

        EditorGUIUtility.labelWidth = 100f;
        serializedObject.Update();
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Button");
        EditorGUILayout.LabelField("Vertical Slots");
        EditorGUILayout.LabelField("Horizontal Slots");
        EditorGUILayout.EndHorizontal();
        for (int i = 0; i < m_ButtonsProperty.arraySize; i++)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(m_ButtonsProperty.GetArrayElementAtIndex(i));
            EditorGUILayout.PropertyField(m_VerticalLayoutTransformsProperty.GetArrayElementAtIndex(i), GUIContent.none);
            EditorGUILayout.PropertyField(m_HorizontalLayoutTransformsProperty.GetArrayElementAtIndex(i), GUIContent.none);
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.PropertyField(m_DirectManipulatorProperty);
        EditorGUILayout.PropertyField(m_SmoothMotionProperty);

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Vertical layout"))
        {
            m_KeyboardUI.ForceMoveButtonsToVerticalLayout();
        }
        if (GUILayout.Button("Horizontal layout"))
        {
            m_KeyboardUI.ForceMoveButtonsToHorizontalLayout();
        }
        EditorGUILayout.EndHorizontal();

        serializedObject.ApplyModifiedProperties();
        EditorGUIUtility.labelWidth = labelWidth;
    }
Esempio n. 6
0
    private void Awake()
    {
        instance = this;
        EventListener.Get(gameObject).onClick += e => {
            gameObject.SetActive(false);
            if (onEnter != null)
            {
                onEnter();
            }
        };

        EventListener.Get(box.gameObject).onEnter += e => {
            isMove = false;
        };

        EventListener.Get(box.gameObject).onExit += e => {
            isMove = true;
        };

        arrays = new bool[50];
        keys   = new Transform[39];

        Button [] buttons = new Button[39];
        for (int i = 0; i < keys.Length; i++)
        {
            buttons[i] = Instantiate(prefab).GetComponent <Button>();
            texts[i]   = buttons[i].GetComponentInChildren <Text>();
            keys[i]    = buttons[i].transform;
            buttons[i].transform.SetParent(parent);
        }

        for (int i = 0; i < 26; i++)
        {
            var ch = (char)(i + 'a');
            texts[i].text = ch.ToString();
            buttons[i].onClick.AddListener(() => { AddToInputField(ch); });
        }

        for (int i = 26; i < 36; i++)
        {
            var ch = (char)(i + '0');
            texts[i].text = ch.ToString();
            buttons[i].onClick.AddListener(() => { AddToInputField(ch); });
        }

        texts[36].text = "shift";
        buttons[36].onClick.AddListener(() => {
            isLower = !isLower;
            ChangedText(isLower?'a':'A');
        });

        texts[37].text = "space";
        buttons[37].onClick.AddListener(() => { AddToInputField(' '); });

        texts[38].text = "Enter";
        buttons[38].onClick.AddListener(() => {
            gameObject.SetActive(false);
            if (onEnter != null)
            {
                onEnter();
            }
        });

        size   = ((RectTransform)buttons[0].transform).sizeDelta;
        maxPos = new Vector2(Screen.width - size.x * 11, Screen.height - size.y * 6);
        var boxTr = ((RectTransform)box.transform);

        boxTr.localPosition            = new Vector3(-10, -10, 0);
        boxTr.sizeDelta                = new Vector2(size.x * 10 + 20, size.y * 5 + 20);
        parent.transform.localPosition = new Vector3(10, 10, 0);
    }
Esempio n. 7
0
 void FinalizeClose()
 {
     m_Keyboard.gameObject.SetActive(false);
     m_Keyboard = null;
 }