示例#1
0
    void OnSelect(bool selected)
    {
        if (textMesh != null && mSelected != selected && enabled && gameObject.active)
        {
            mSelected = selected;

            if (mSelected)
            {
                mText = textMesh.text;

#if UNITY_IPHONE || UNITY_ANDROID
                if (Application.platform == RuntimePlatform.IPhonePlayer ||
                    Application.platform == RuntimePlatform.Android)
                {
                    mKeyboard = iPhoneKeyboard.Open(mText);
                }
                else
#endif
                {
                    textMesh.text = mText + "|";
                }
            }
#if UNITY_IPHONE || UNITY_ANDROID
            else if (mKeyboard != null)
            {
                mKeyboard.active = false;
            }
#endif
            else
            {
                textMesh.text = mText;
            }
        }
    }
示例#2
0
    /// <summary>
    /// Update the text and the label by grabbing it from the iOS/Android keyboard.
    /// </summary>

    void Update()
    {
        if (mKeyboard != null)
        {
            string text = mKeyboard.text;

            if (mText != text)
            {
                mText = text;
                UpdateLabel();
            }

            if (mKeyboard.done)
            {
                mKeyboard = null;
                current   = this;
                if (eventReceiver == null)
                {
                    eventReceiver = gameObject;
                }
                eventReceiver.SendMessage(functionName, SendMessageOptions.DontRequireReceiver);
                current  = null;
                selected = false;
            }
        }
    }
示例#3
0
    void OnClick()
    {
//		Debug.Log (string.Format ("---------------------------inputClick,{0},{1},{2},{3},{4}",isInput,playerID,playerName,this.transform.parent.name,this.text));
        if (isInput)
        {
//			Debug.Log ("------------------------OnClickInput");
            isSelect = true;
#if UNITY_IPHONE || UNITY_ANDROID
            keyboard = TouchScreenKeyboard.Open(Text, TouchScreenKeyboardType.Default);
#endif
        }
        else
        {
//			Debug.Log (string.Format ("{0},{1}",playerID,BtnGameManager.yt.Rows[0]["PlayerID"].YuanColumnText));
            if (playerID != "" && playerID != BtnGameManager.yt.Rows[0]["PlayerID"].YuanColumnText)
            {
                strPlayer[0] = playerID;
                strPlayer[1] = playerName;
//				Debug.Log ("YYYYYYYYYYYYYYYYYYYYYYYY");
                if (btnSend != null)
                {
                    //btnSend.ShowOne(this,strPlayer);
                    PanelStatic.StaticBtnGameManager.RunShowOne((object)strPlayer);
                }
            }
        }
    }
示例#4
0
    /// <summary>
    /// Update the text and the label by grabbing it from the iOS/Android keyboard.
    /// </summary>

    void Update()
    {
        if (mKeyboard != null)
        {
            string text = mKeyboard.text;

            if (mText != text)
            {
                mText = text;
                UpdateLabel();
            }

            if (mKeyboard.done)
            {
                mKeyboard = null;
                gameObject.SendMessage("OnSubmit", SendMessageOptions.DontRequireReceiver);
                if (MsgReceiver != null)
                {
                    MsgReceiver.SendMessage("OnEventWithMessage", new LuaMessage(gameObject, this, "OnSubmit"), SendMessageOptions.DontRequireReceiver);
                }
                selected = false;
            }

            if (mKeyboard != null && !mKeyboard.active)
            {
                selected = false;
            }
        }
    }
示例#5
0
    /// <summary>
    /// Selection event, sent by UICamera.
    /// </summary>

    void OnSelect(bool isSelected)
    {
        if (label != null && enabled && gameObject.active)
        {
            if (isSelected)
            {
                mText       = (label.text == mDefaultText) ? "" : label.text;
                label.color = activeColor;

#if UNITY_IPHONE || UNITY_ANDROID
                if (Application.platform == RuntimePlatform.IPhonePlayer ||
                    Application.platform == RuntimePlatform.Android)
                {
#if UNITY_3_4
                    mKeyboard = iPhoneKeyboard.Open(mText);
#else
                    mKeyboard = TouchScreenKeyboard.Open(mText);
#endif
                }
                else
#endif
                {
                    Input.imeCompositionMode = IMECompositionMode.On;
                    Transform t      = label.cachedTransform;
                    Vector3   offset = label.pivotOffset;
                    offset.y += label.relativeSize.y;
                    offset    = t.TransformPoint(offset);
                    Input.compositionCursorPos = UICamera.lastCamera.WorldToScreenPoint(offset);
                    UpdateLabel();
                }
            }
#if UNITY_IPHONE || UNITY_ANDROID
            else if (mKeyboard != null)
            {
                mKeyboard.active = false;
            }
#endif
            else
            {
                if (string.IsNullOrEmpty(mText))
                {
                    label.text  = mDefaultText;
                    label.color = mDefaultColor;
                }
                else
                {
                    label.text = mText;
                }

                label.showLastPasswordChar = false;
                Input.imeCompositionMode   = IMECompositionMode.Off;
            }
        }
    }
示例#6
0
    /// <summary>
    /// Update the text and the label by grabbing it from the iOS/Android keyboard.
    /// </summary>

    void Update()
    {
        if (mKeyboard != null)
        {
            string text = mKeyboard.text;

            if (mText != text)
            {
                mText = "";

                for (int i = 0; i < text.Length; ++i)
                {
                    char ch = text[i];
                    if (validator != null)
                    {
                        ch = validator(mText, ch);
                    }
                    if (ch != 0)
                    {
                        mText += ch;
                    }
                }

                if (maxChars > 0 && mText.Length > maxChars)
                {
                    mText = mText.Substring(0, maxChars);
                }
                if (mText != text)
                {
                    mKeyboard.text = mText;
                }
                UpdateLabel();
                SendMessage("OnInputChanged", this, SendMessageOptions.DontRequireReceiver);
            }

            if (mKeyboard.done)
            {
                mKeyboard = null;
                current   = this;
                if (onSubmit != null)
                {
                    onSubmit(mText);
                }
                if (eventReceiver == null)
                {
                    eventReceiver = gameObject;
                }
                eventReceiver.SendMessage(functionName, mText, SendMessageOptions.DontRequireReceiver);
                current  = null;
                selected = false;
            }
        }
    }
示例#7
0
    void OnInput(string input)
    {
        if (mSelected && enabled && gameObject.active)
        {
#if UNITY_IPHONE || UNITY_ANDROID
            if (mKeyboard != null && mKeyboard.done)
            {
                mSelected = false;
                mKeyboard = null;
                mText     = "";
            }
#endif
            foreach (char c in input)
            {
                if (c == '\b')
                {
                    // Backspace
                    if (mText.Length > 0)
                    {
                        mText = mText.Substring(0, mText.Length - 1);
                    }
                }
                else if (c == '\r' || c == '\n')
                {
                    // Enter
                    OnSelect(false);
                    return;
                }
                else
                {
                    // All other characters get appended to the text
                    mText += c;
                }
            }
            textMesh.text = mSelected ? (mText + "|") : mText;
        }
    }
示例#8
0
文件: UIInput.cs 项目: happylays/tbb2
    /// <summary>
    /// Selection event, sent by UICamera.
    /// </summary>

    void OnSelect(bool isSelected)
    {
        if (mDoInit)
        {
            Init();
        }

        if (label != null && enabled && NGUITools.GetActive(gameObject))
        {
            if (isSelected)
            {
                mText       = (!useLabelTextAtStart && label.text == mDefaultText) ? "" : label.text;
                label.color = activeColor;
                if (isPassword)
                {
                    label.password = true;
                }

#if UNITY_IPHONE || UNITY_ANDROID
                if (Application.platform == RuntimePlatform.IPhonePlayer ||
                    Application.platform == RuntimePlatform.Android)
                {
                    //TouchScreenKeyboard.hideInput = true;
                    try
                    {
                                                #if UNITY_3_4
                        mKeyboard = iPhoneKeyboard.Open(mText, (iPhoneKeyboardType)((int)type), autoCorrect);
                                                #else
                        if (isPassword)
                        {
                            mKeyboard = TouchScreenKeyboard.Open(mText, TouchScreenKeyboardType.Default, false, false, true);
                        }
                        else
                        {
                            mKeyboard = TouchScreenKeyboard.Open(mText, (TouchScreenKeyboardType)((int)type), autoCorrect);
                        }
                                                #endif
                    }
                    catch (System.Exception ex)
                    {
                        mText = "^_^";
                                                #if UNITY_3_4
                        mKeyboard = iPhoneKeyboard.Open(mText, (iPhoneKeyboardType)((int)type), autoCorrect);
                                                #else
                        if (isPassword)
                        {
                            mKeyboard = TouchScreenKeyboard.Open(mText, TouchScreenKeyboardType.Default, false, false, true);
                        }
                        else
                        {
                            mKeyboard = TouchScreenKeyboard.Open(mText, (TouchScreenKeyboardType)((int)type), autoCorrect);
                        }
                                                #endif
                        Debug.LogError("Input error.Invalid." + ex);
                    }
                }
                else
#endif
                {
                    Input.imeCompositionMode = IMECompositionMode.On;
                    Transform t      = label.cachedTransform;
                    Vector3   offset = label.pivotOffset;
                    offset.y += label.relativeSize.y;
                    offset    = t.TransformPoint(offset);
                    Input.compositionCursorPos = UICamera.currentCamera.WorldToScreenPoint(offset);
                }
                UpdateLabel();
            }
            else
            {
#if UNITY_IPHONE || UNITY_ANDROID
                if (mKeyboard != null)
                {
                    mKeyboard.active = false;
                }
#endif
                if (string.IsNullOrEmpty(mText))
                {
                    label.text  = mDefaultText;
                    label.color = mDefaultColor;
                    if (isPassword)
                    {
                        label.password = false;
                    }
                }
                else
                {
                    label.text = mText;
                }

                label.showLastPasswordChar = false;
                Input.imeCompositionMode   = IMECompositionMode.Off;
                RestoreLabel();
            }
        }
    }