Ejemplo n.º 1
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;
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Update the text and the label by grabbing it from the iOS/Android keyboard.
    /// </summary>
    void Update()
    {
        if (mKeyboard != null)
        {
            mText = mKeyboard.text;
            UpdateLabel();

            if (mKeyboard.done)
            {
                mKeyboard = null;
                gameObject.SendMessage("OnSubmit", SendMessageOptions.DontRequireReceiver);
                selected = false;
            }
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Selection event, sent by UICamera.
    /// </summary>
    void OnSelect(bool isSelected)
    {
        if (label != null && enabled && gameObject.active)
        {
            if (isSelected)
            {
                mText = label.text;

        #if UNITY_IPHONE || UNITY_ANDROID
                if (Application.platform == RuntimePlatform.IPhonePlayer ||
                    Application.platform == RuntimePlatform.Android)
                {
                    mKeyboard = iPhoneKeyboard.Open(mText);
                }
                else
        #endif
                {
                    label.text = mText + caratChar;
                    label.showLastPasswordChar = isSelected;

                    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);
                }
            }
        #if UNITY_IPHONE || UNITY_ANDROID
            else if (mKeyboard != null)
            {
                mKeyboard.active = false;
            }
        #endif
            else
            {
                label.text = mText;
                label.showLastPasswordChar = isSelected;
                Input.imeCompositionMode = IMECompositionMode.Off;
            }
        }
    }
Ejemplo n.º 4
0
    void Start()
    {
        // iPhoneKeyboard.autorotateToPortrait = false;
        //         iPhoneKeyboard.autorotateToPortraitUpsideDown  = false;
        //         iPhoneKeyboard.autorotateToLandscapeRight  = false;
        //         iPhoneKeyboard.autorotateToLandscapeLeft = true;

        players = new PlayerScore[maxPlayer];
        int index = 0;
        string key = "";
        while(index < maxPlayer) {
            key = "player" + index;
            if(PlayerPrefs.HasKey(key)) {
                players[index] = new PlayerScore(PlayerPrefs.GetString(key));
            } else {
                players[index] = new PlayerScore();
            }
            players[index].id = index;
            players[index].rect = new Rect(120, 70 + index * 24, 300, 24);
            players[index].textStyle = textStyle;
            index++;
        }
        if(PlayerPrefs.HasKey("player")) {
            PlayerScore newPlayer = new PlayerScore(PlayerPrefs.GetString("player"));
            newPlayerPosition = maxPlayer;
            for(index = maxPlayer - 1; index >= 0 ; index--) {
                if(players[index].getWeight() < newPlayer.getWeight()) {
                    if((index + 1) < maxPlayer) {
                        players[index + 1].Copy(players[index]);
                    }
                    players[index].Copy(newPlayer);
                    newPlayerPosition = index;
                }
            }
            if(newPlayerPosition < maxPlayer)
                keyboard = iPhoneKeyboard.Open(players[newPlayerPosition].name, iPhoneKeyboardType.Default);
            MainMenu.CleanPlayerPrefs();
        }

        GameMaster.SetGame(false);
    }
Ejemplo n.º 5
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;
            }
        }
    }