Exemplo n.º 1
0
 protected virtual void Update()
 {
     //IL_000c: Unknown result type (might be due to invalid IL or missing references)
     //IL_0028: Unknown result type (might be due to invalid IL or missing references)
     //IL_0039: Unknown result type (might be due to invalid IL or missing references)
     //IL_006f: Unknown result type (might be due to invalid IL or missing references)
     //IL_0092: Unknown result type (might be due to invalid IL or missing references)
     //IL_00f3: Unknown result type (might be due to invalid IL or missing references)
     //IL_00f8: Expected O, but got Unknown
     //IL_0115: Unknown result type (might be due to invalid IL or missing references)
     //IL_011a: Expected O, but got Unknown
     if (!UICamera.inputHasFocus && (int)keyCode != 0 && IsModifierActive())
     {
         bool flag  = UICamera.GetKeyDown(keyCode);
         bool flag2 = UICamera.GetKeyUp(keyCode);
         if (flag)
         {
             mPress = true;
         }
         if (action == Action.PressAndClick || action == Action.All)
         {
             if (flag)
             {
                 UICamera.currentKey = keyCode;
                 OnBindingPress(true);
             }
             if (mPress && flag2)
             {
                 UICamera.currentKey = keyCode;
                 OnBindingPress(false);
                 OnBindingClick();
             }
         }
         if ((action == Action.Select || action == Action.All) && flag2)
         {
             if (mIsInput)
             {
                 if (!mIgnoreUp && !UICamera.inputHasFocus && mPress)
                 {
                     UICamera.selectedObject = this.get_gameObject();
                 }
                 mIgnoreUp = false;
             }
             else if (mPress)
             {
                 UICamera.hoveredObject = this.get_gameObject();
             }
         }
         if (flag2)
         {
             mPress = false;
         }
     }
 }
Exemplo n.º 2
0
    protected virtual void Update()
    {
        if (UICamera.inputHasFocus)
        {
            return;
        }
        if (this.keyCode == KeyCode.None || !this.IsModifierActive())
        {
            return;
        }
        bool flag  = UICamera.GetKeyDown(this.keyCode);
        bool flag2 = UICamera.GetKeyUp(this.keyCode);

        if (flag)
        {
            this.mPress = true;
        }
        if (this.action == UIKeyBinding.Action.PressAndClick || this.action == UIKeyBinding.Action.All)
        {
            if (flag)
            {
                UICamera.currentKey = this.keyCode;
                this.OnBindingPress(true);
            }
            if (this.mPress && flag2)
            {
                UICamera.currentKey = this.keyCode;
                this.OnBindingPress(false);
                this.OnBindingClick();
            }
        }
        if ((this.action == UIKeyBinding.Action.Select || this.action == UIKeyBinding.Action.All) && flag2)
        {
            if (this.mIsInput)
            {
                if (!this.mIgnoreUp && !UICamera.inputHasFocus && this.mPress)
                {
                    UICamera.selectedObject = base.gameObject;
                }
                this.mIgnoreUp = false;
            }
            else
            {
                if (this.mPress)
                {
                    UICamera.hoveredObject = base.gameObject;
                }
            }
        }
        if (flag2)
        {
            this.mPress = false;
        }
    }
Exemplo n.º 3
0
	/// <summary>
	/// Process the key binding.
	/// </summary>

	protected virtual void Update ()
	{
		if (UICamera.inputHasFocus) return;
		if (keyCode == KeyCode.None || !IsModifierActive()) return;

		bool keyDown = UICamera.GetKeyDown(keyCode);
		bool keyUp = UICamera.GetKeyUp(keyCode);

		if (keyDown) mPress = true;

		if (action == Action.PressAndClick || action == Action.All)
		{
			if (keyDown)
			{
				UICamera.currentKey = keyCode;
				OnBindingPress(true);
			}

			if (mPress && keyUp)
			{
				UICamera.currentKey = keyCode;
				OnBindingPress(false);
				OnBindingClick();
			}
		}

		if (action == Action.Select || action == Action.All)
		{
			if (keyUp)
			{
				if (mIsInput)
				{
					if (!mIgnoreUp && !UICamera.inputHasFocus)
					{
						if (mPress) UICamera.selectedObject = gameObject;
					}
					mIgnoreUp = false;
				}
				else if (mPress)
				{
					UICamera.hoveredObject = gameObject;
				}
			}
		}

		if (keyUp) mPress = false;
	}
Exemplo n.º 4
0
    /// <summary>
    /// Process the key binding.
    /// </summary>

    protected virtual void Update()
    {
        if (UICamera.inputHasFocus)
        {
            return;
        }
        if (keyCode == KeyCode.None || !IsModifierActive())
        {
            return;
        }
#if WINDWARD && UNITY_ANDROID
        // NVIDIA Shield controller has an odd bug where it can open the on-screen keyboard via a KeyCode.Return binding,
        // and then it can never be closed. I am disabling it here until I can track down the cause.
        if (keyCode == KeyCode.Return && PlayerPrefs.GetInt("Start Chat") == 0)
        {
            return;
        }
#endif

#if UNITY_FLASH
        bool keyDown = Input.GetKeyDown(keyCode);
        bool keyUp   = Input.GetKeyUp(keyCode);
#else
        bool keyDown = UICamera.GetKeyDown(keyCode);
        bool keyUp   = UICamera.GetKeyUp(keyCode);
#endif

        if (keyDown)
        {
            mPress = true;
        }

        if (action == Action.PressAndClick || action == Action.All)
        {
            if (keyDown)
            {
                UICamera.currentKey = keyCode;
                OnBindingPress(true);
            }

            if (mPress && keyUp)
            {
                UICamera.currentKey = keyCode;
                OnBindingPress(false);
                OnBindingClick();
            }
        }

        if (action == Action.Select || action == Action.All)
        {
            if (keyUp)
            {
                if (mIsInput)
                {
                    if (!mIgnoreUp && !UICamera.inputHasFocus)
                    {
                        if (mPress)
                        {
                            UICamera.selectedObject = gameObject;
                        }
                    }
                    mIgnoreUp = false;
                }
                else if (mPress)
                {
                    UICamera.hoveredObject = gameObject;
                }
            }
        }

        if (keyUp)
        {
            mPress = false;
        }
    }
Exemplo n.º 5
0
 protected virtual void Update()
 {
     if (!this.isSelected || this.mSelectTime == Time.frameCount)
     {
         return;
     }
     if (this.mDoInit)
     {
         this.Init();
     }
     if (UIInput.mWaitForKeyboard)
     {
         if (UIInput.mKeyboard != null && !UIInput.mKeyboard.active)
         {
             return;
         }
         UIInput.mWaitForKeyboard = false;
     }
     if (this.mSelectMe != -1 && this.mSelectMe != Time.frameCount)
     {
         this.mSelectMe       = -1;
         this.mSelectionEnd   = ((!string.IsNullOrEmpty(this.mValue)) ? this.mValue.Length : 0);
         UIInput.mDrawStart   = 0;
         this.mSelectionStart = ((!this.selectAllTextOnFocus) ? this.mSelectionEnd : 0);
         this.label.color     = this.activeTextColor;
         RuntimePlatform platform = Application.platform;
         if (platform == RuntimePlatform.IPhonePlayer || platform == RuntimePlatform.Android || platform == RuntimePlatform.MetroPlayerARM || platform == RuntimePlatform.MetroPlayerX64 || platform == RuntimePlatform.MetroPlayerX86)
         {
             TouchScreenKeyboardType touchScreenKeyboardType;
             string text;
             if (this.inputShouldBeHidden)
             {
                 TouchScreenKeyboard.hideInput = true;
                 touchScreenKeyboardType       = (TouchScreenKeyboardType)this.keyboardType;
                 text = "|";
             }
             else if (this.inputType == UIInput.InputType.Password)
             {
                 TouchScreenKeyboard.hideInput = false;
                 touchScreenKeyboardType       = (TouchScreenKeyboardType)this.keyboardType;
                 text = this.mValue;
                 this.mSelectionStart = this.mSelectionEnd;
             }
             else
             {
                 TouchScreenKeyboard.hideInput = false;
                 touchScreenKeyboardType       = (TouchScreenKeyboardType)this.keyboardType;
                 text = this.mValue;
                 this.mSelectionStart = this.mSelectionEnd;
             }
             UIInput.mWaitForKeyboard = true;
             UIInput.mKeyboard        = ((this.inputType != UIInput.InputType.Password) ? TouchScreenKeyboard.Open(text, touchScreenKeyboardType, !this.inputShouldBeHidden && this.inputType == UIInput.InputType.AutoCorrect, this.label.multiLine && !this.hideInput, false, false, this.defaultText) : TouchScreenKeyboard.Open(text, touchScreenKeyboardType, false, false, true));
         }
         else
         {
             Vector2 compositionCursorPos = (!(UICamera.current != null) || !(UICamera.current.cachedCamera != null)) ? this.label.worldCorners[0] : UICamera.current.cachedCamera.WorldToScreenPoint(this.label.worldCorners[0]);
             compositionCursorPos.y     = (float)Screen.height - compositionCursorPos.y;
             Input.imeCompositionMode   = IMECompositionMode.On;
             Input.compositionCursorPos = compositionCursorPos;
         }
         this.UpdateLabel();
         if (string.IsNullOrEmpty(Input.inputString))
         {
             return;
         }
     }
     if (UIInput.mKeyboard != null)
     {
         string text2 = (!UIInput.mKeyboard.done && UIInput.mKeyboard.active) ? UIInput.mKeyboard.text : this.mCached;
         if (this.inputShouldBeHidden)
         {
             if (text2 != "|")
             {
                 if (!string.IsNullOrEmpty(text2))
                 {
                     this.Insert(text2.Substring(1));
                 }
                 else if (!UIInput.mKeyboard.done && UIInput.mKeyboard.active)
                 {
                     this.DoBackspace();
                 }
                 UIInput.mKeyboard.text = "|";
             }
         }
         else if (this.mCached != text2)
         {
             this.mCached = text2;
             if (!UIInput.mKeyboard.done && UIInput.mKeyboard.active)
             {
                 this.value = text2;
             }
         }
         if (UIInput.mKeyboard.done || !UIInput.mKeyboard.active)
         {
             if (!UIInput.mKeyboard.wasCanceled)
             {
                 this.Submit();
             }
             UIInput.mKeyboard = null;
             this.isSelected   = false;
             this.mCached      = string.Empty;
         }
     }
     else
     {
         string compositionString = Input.compositionString;
         if (string.IsNullOrEmpty(compositionString) && !string.IsNullOrEmpty(Input.inputString))
         {
             string inputString = Input.inputString;
             for (int i = 0; i < inputString.Length; i++)
             {
                 char c = inputString[i];
                 if (c >= ' ')
                 {
                     if (c != '')
                     {
                         if (c != '')
                         {
                             if (c != '')
                             {
                                 if (c != '')
                                 {
                                     if (c != '')
                                     {
                                         this.Insert(c.ToString());
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (UIInput.mLastIME != compositionString)
         {
             this.mSelectionEnd = ((!string.IsNullOrEmpty(compositionString)) ? (this.mValue.Length + compositionString.Length) : this.mSelectionStart);
             UIInput.mLastIME   = compositionString;
             this.UpdateLabel();
             this.ExecuteOnChange();
         }
     }
     if (this.mCaret != null && this.mNextBlink < RealTime.time)
     {
         this.mNextBlink     = RealTime.time + 0.5f;
         this.mCaret.enabled = !this.mCaret.enabled;
     }
     if (this.isSelected && this.mLastAlpha != this.label.finalAlpha)
     {
         this.UpdateLabel();
     }
     if (this.mCam == null)
     {
         this.mCam = UICamera.FindCameraForLayer(base.gameObject.layer);
     }
     if (this.mCam != null)
     {
         bool flag = false;
         if (this.label.multiLine)
         {
             bool flag2 = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
             if (this.onReturnKey == UIInput.OnReturnKey.Submit)
             {
                 flag = flag2;
             }
             else
             {
                 flag = !flag2;
             }
         }
         if (UICamera.GetKeyDown(this.mCam.submitKey0) || (this.mCam.submitKey0 == KeyCode.Return && UICamera.GetKeyDown(KeyCode.KeypadEnter)))
         {
             if (flag)
             {
                 this.Insert("\n");
             }
             else
             {
                 if (UICamera.controller.current != null)
                 {
                     UICamera.controller.clickNotification = UICamera.ClickNotification.None;
                 }
                 UICamera.currentKey = this.mCam.submitKey0;
                 this.Submit();
             }
         }
         if (UICamera.GetKeyDown(this.mCam.submitKey1) || (this.mCam.submitKey1 == KeyCode.Return && UICamera.GetKeyDown(KeyCode.KeypadEnter)))
         {
             if (flag)
             {
                 this.Insert("\n");
             }
             else
             {
                 if (UICamera.controller.current != null)
                 {
                     UICamera.controller.clickNotification = UICamera.ClickNotification.None;
                 }
                 UICamera.currentKey = this.mCam.submitKey1;
                 this.Submit();
             }
         }
         if (!this.mCam.useKeyboard && UICamera.GetKeyUp(KeyCode.Tab))
         {
             this.OnKey(KeyCode.Tab);
         }
     }
 }
Exemplo n.º 6
0
    protected virtual void Update()
    {
        if (!this.isSelected || this.mSelectTime == Time.frameCount)
        {
            return;
        }
        if (this.mDoInit)
        {
            this.Init();
        }
        if (this.mSelectMe != -1 && this.mSelectMe != Time.frameCount)
        {
            this.mSelectMe       = -1;
            this.mSelectionEnd   = ((!string.IsNullOrEmpty(this.mValue)) ? this.mValue.Length : 0);
            UIInput.mDrawStart   = 0;
            this.mSelectionStart = ((!this.selectAllTextOnFocus) ? this.mSelectionEnd : 0);
            this.label.color     = this.activeTextColor;
            Vector2 compositionCursorPos = (!(UICamera.current != null) || !(UICamera.current.cachedCamera != null)) ? this.label.worldCorners[0] : UICamera.current.cachedCamera.WorldToScreenPoint(this.label.worldCorners[0]);
            compositionCursorPos.y     = (float)Screen.height - compositionCursorPos.y;
            Input.imeCompositionMode   = IMECompositionMode.On;
            Input.compositionCursorPos = compositionCursorPos;
            this.UpdateLabel();
            if (string.IsNullOrEmpty(Input.inputString))
            {
                return;
            }
        }
        string compositionString = Input.compositionString;

        if (string.IsNullOrEmpty(compositionString) && !string.IsNullOrEmpty(Input.inputString))
        {
            string inputString = Input.inputString;
            for (int i = 0; i < inputString.Length; i++)
            {
                char c = inputString[i];
                if (c >= ' ')
                {
                    if (c != '')
                    {
                        if (c != '')
                        {
                            if (c != '')
                            {
                                if (c != '')
                                {
                                    this.Insert(c.ToString());
                                }
                            }
                        }
                    }
                }
            }
        }
        if (UIInput.mLastIME != compositionString)
        {
            this.mSelectionEnd = ((!string.IsNullOrEmpty(compositionString)) ? (this.mValue.Length + compositionString.Length) : this.mSelectionStart);
            UIInput.mLastIME   = compositionString;
            this.UpdateLabel();
            this.ExecuteOnChange();
        }
        if (this.mCaret != null && this.mNextBlink < RealTime.time)
        {
            this.mNextBlink     = RealTime.time + 0.5f;
            this.mCaret.enabled = !this.mCaret.enabled;
        }
        if (this.isSelected && this.mLastAlpha != this.label.finalAlpha)
        {
            this.UpdateLabel();
        }
        if (this.mCam == null)
        {
            this.mCam = UICamera.FindCameraForLayer(base.gameObject.layer);
        }
        if (this.mCam != null)
        {
            if (UICamera.GetKeyDown(this.mCam.submitKey0))
            {
                bool flag = this.onReturnKey == UIInput.OnReturnKey.NewLine || (this.onReturnKey == UIInput.OnReturnKey.Default && this.label.multiLine && !Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl) && this.label.overflowMethod != UILabel.Overflow.ClampContent && this.validation == UIInput.Validation.None);
                if (flag)
                {
                    this.Insert("\n");
                }
                else
                {
                    if (UICamera.controller.current != null)
                    {
                        UICamera.controller.clickNotification = UICamera.ClickNotification.None;
                    }
                    UICamera.currentKey = this.mCam.submitKey0;
                    this.Submit();
                }
            }
            if (UICamera.GetKeyDown(this.mCam.submitKey1))
            {
                bool flag2 = this.onReturnKey == UIInput.OnReturnKey.NewLine || (this.onReturnKey == UIInput.OnReturnKey.Default && this.label.multiLine && !Input.GetKey(KeyCode.LeftControl) && !Input.GetKey(KeyCode.RightControl) && this.label.overflowMethod != UILabel.Overflow.ClampContent && this.validation == UIInput.Validation.None);
                if (flag2)
                {
                    this.Insert("\n");
                }
                else
                {
                    if (UICamera.controller.current != null)
                    {
                        UICamera.controller.clickNotification = UICamera.ClickNotification.None;
                    }
                    UICamera.currentKey = this.mCam.submitKey1;
                    this.Submit();
                }
            }
            if (!this.mCam.useKeyboard && UICamera.GetKeyUp(KeyCode.Tab))
            {
                this.OnKey(KeyCode.Tab);
            }
        }
    }
Exemplo n.º 7
0
    // Token: 0x060007A1 RID: 1953 RVA: 0x0003EDDC File Offset: 0x0003CFDC
    protected virtual void Update()
    {
        if (!this.isSelected || this.mSelectTime == Time.frameCount)
        {
            return;
        }
        if (this.mDoInit)
        {
            this.Init();
        }
        if (this.mSelectMe != -1 && this.mSelectMe != Time.frameCount)
        {
            this.mSelectMe       = -1;
            this.mSelectionEnd   = (string.IsNullOrEmpty(this.mValue) ? 0 : this.mValue.Length);
            UIInput.mDrawStart   = 0;
            this.mSelectionStart = (this.selectAllTextOnFocus ? 0 : this.mSelectionEnd);
            this.label.color     = this.activeTextColor;
            Vector2 vector = (UICamera.current != null && UICamera.current.cachedCamera != null) ? UICamera.current.cachedCamera.WorldToScreenPoint(this.label.worldCorners[0]) : this.label.worldCorners[0];
            vector.y = (float)Screen.height - vector.y;
            Input.imeCompositionMode   = IMECompositionMode.On;
            Input.compositionCursorPos = vector;
            this.UpdateLabel();
            if (string.IsNullOrEmpty(Input.inputString))
            {
                return;
            }
        }
        string compositionString = Input.compositionString;

        if (string.IsNullOrEmpty(compositionString) && !string.IsNullOrEmpty(Input.inputString))
        {
            foreach (char c in Input.inputString)
            {
                if (c >= ' ' && c != '' && c != '' && c != '' && c != '' && c != '')
                {
                    this.Insert(c.ToString());
                }
            }
        }
        if (UIInput.mLastIME != compositionString)
        {
            this.mSelectionEnd = (string.IsNullOrEmpty(compositionString) ? this.mSelectionStart : (this.mValue.Length + compositionString.Length));
            UIInput.mLastIME   = compositionString;
            this.UpdateLabel();
            this.ExecuteOnChange();
        }
        if (this.mCaret != null && this.mNextBlink < RealTime.time)
        {
            this.mNextBlink     = RealTime.time + 0.5f;
            this.mCaret.enabled = !this.mCaret.enabled;
        }
        if (this.isSelected && this.mLastAlpha != this.label.finalAlpha)
        {
            this.UpdateLabel();
        }
        if (this.mCam == null)
        {
            this.mCam = UICamera.FindCameraForLayer(base.gameObject.layer);
        }
        if (this.mCam != null)
        {
            bool flag = false;
            if (this.label.multiLine)
            {
                bool flag2 = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
                if (this.onReturnKey == UIInput.OnReturnKey.Submit)
                {
                    flag = flag2;
                }
                else
                {
                    flag = !flag2;
                }
            }
            if (UICamera.GetKeyDown(this.mCam.submitKey0) || (this.mCam.submitKey0 == KeyCode.Return && UICamera.GetKeyDown(KeyCode.KeypadEnter)))
            {
                if (flag)
                {
                    this.Insert("\n");
                }
                else
                {
                    if (UICamera.controller.current != null)
                    {
                        UICamera.controller.clickNotification = UICamera.ClickNotification.None;
                    }
                    UICamera.currentKey = this.mCam.submitKey0;
                    this.Submit();
                }
            }
            if (UICamera.GetKeyDown(this.mCam.submitKey1) || (this.mCam.submitKey1 == KeyCode.Return && UICamera.GetKeyDown(KeyCode.KeypadEnter)))
            {
                if (flag)
                {
                    this.Insert("\n");
                }
                else
                {
                    if (UICamera.controller.current != null)
                    {
                        UICamera.controller.clickNotification = UICamera.ClickNotification.None;
                    }
                    UICamera.currentKey = this.mCam.submitKey1;
                    this.Submit();
                }
            }
            if (!this.mCam.useKeyboard && UICamera.GetKeyUp(KeyCode.Tab))
            {
                this.OnKey(KeyCode.Tab);
            }
        }
    }
Exemplo n.º 8
0
	/// <summary>
	/// Update the text based on input.
	/// </summary>
	
	protected virtual void Update ()
	{
#if UNITY_EDITOR
		if (!Application.isPlaying) return;
#endif
		if (!isSelected || mSelectTime == Time.frameCount) return;

		if (mDoInit) Init();
#if MOBILE
		// Wait for the keyboard to open. Apparently mKeyboard.active will return 'false' for a while in some cases.
		if (mWaitForKeyboard)
		{
			if (mKeyboard != null && !mKeyboard.active) return;
			mWaitForKeyboard = false;
		}
#endif
		// Unity has issues bringing up the keyboard properly if it's in "hideInput" mode and you happen
		// to select one input in the same Update as de-selecting another.
		if (mSelectMe != -1 && mSelectMe != Time.frameCount)
		{
			mSelectMe = -1;
			mSelectionEnd = string.IsNullOrEmpty(mValue) ? 0 : mValue.Length;
			mDrawStart = 0;
			mSelectionStart = selectAllTextOnFocus ? 0 : mSelectionEnd;
			label.color = activeTextColor;
#if MOBILE
			RuntimePlatform pf = Application.platform;
			if (pf == RuntimePlatform.IPhonePlayer
				|| pf == RuntimePlatform.Android
				|| pf == RuntimePlatform.WP8Player
 #if UNITY_4_3
				|| pf == RuntimePlatform.BB10Player
 #else
				|| pf == RuntimePlatform.BlackBerryPlayer
				|| pf == RuntimePlatform.MetroPlayerARM
				|| pf == RuntimePlatform.MetroPlayerX64
				|| pf == RuntimePlatform.MetroPlayerX86
 #endif
			)
			{
				string val;
				TouchScreenKeyboardType kt;

				if (inputShouldBeHidden)
				{
					TouchScreenKeyboard.hideInput = true;
					kt = (TouchScreenKeyboardType)((int)keyboardType);
					val = "|";
				}
				else if (inputType == InputType.Password)
				{
					TouchScreenKeyboard.hideInput = false;
					kt = (TouchScreenKeyboardType)((int)keyboardType);
					val = mValue;
					mSelectionStart = mSelectionEnd;
				}
				else
				{
					TouchScreenKeyboard.hideInput = false;
					kt = (TouchScreenKeyboardType)((int)keyboardType);
					val = mValue;
					mSelectionStart = mSelectionEnd;
				}

				mWaitForKeyboard = true;
				mKeyboard = (inputType == InputType.Password) ?
					TouchScreenKeyboard.Open(val, kt, false, false, true) :
					TouchScreenKeyboard.Open(val, kt, !inputShouldBeHidden && inputType == InputType.AutoCorrect,
						label.multiLine && !hideInput, false, false, defaultText);
#if UNITY_METRO
				mKeyboard.active = true;
#endif
			}
			else
#endif // MOBILE
			{
				Vector2 pos = (UICamera.current != null && UICamera.current.cachedCamera != null) ?
					UICamera.current.cachedCamera.WorldToScreenPoint(label.worldCorners[0]) :
					label.worldCorners[0];
				pos.y = Screen.height - pos.y;
				Input.imeCompositionMode = IMECompositionMode.On;
				Input.compositionCursorPos = pos;
			}

			UpdateLabel();
			if (string.IsNullOrEmpty(Input.inputString)) return;
		}
#if MOBILE
		if (mKeyboard != null)
		{
			string text = (mKeyboard.done || !mKeyboard.active) ? mCached : mKeyboard.text;
 
			if (inputShouldBeHidden)
			{
				if (text != "|")
				{
					if (!string.IsNullOrEmpty(text))
					{
						Insert(text.Substring(1));
					}
					else if (!mKeyboard.done && mKeyboard.active)
					{
						DoBackspace();
					}
					mKeyboard.text = "|";
				}
			}
			else if (mCached != text)
			{
				mCached = text;
				if (!mKeyboard.done && mKeyboard.active) value = text;
			}

			if (mKeyboard.done || !mKeyboard.active)
			{
				if (!mKeyboard.wasCanceled) Submit();
				mKeyboard = null;
				isSelected = false;
				mCached = "";
			}
		}
		else
#endif // MOBILE
		{
			string ime = Input.compositionString;

			// There seems to be an inconsistency between IME on Windows, and IME on OSX.
			// On Windows, Input.inputString is always empty while IME is active. On the OSX it is not.
			if (string.IsNullOrEmpty(ime) && !string.IsNullOrEmpty(Input.inputString))
			{
				// Process input ignoring non-printable characters as they are not consistent.
				// Windows has them, OSX may not. They get handled inside OnGUI() instead.
				string s = Input.inputString;

				for (int i = 0; i < s.Length; ++i)
				{
					char ch = s[i];
					if (ch < ' ') continue;

					// OSX inserts these characters for arrow keys
					if (ch == '\uF700') continue;
					if (ch == '\uF701') continue;
					if (ch == '\uF702') continue;
					if (ch == '\uF703') continue;
					if (ch == '\uF728') continue;

					Insert(ch.ToString());
				}
			}

			// Append IME composition
			if (mLastIME != ime)
			{
				mSelectionEnd = string.IsNullOrEmpty(ime) ? mSelectionStart : mValue.Length + ime.Length;
				mLastIME = ime;
				UpdateLabel();
				ExecuteOnChange();
			}
		}

		// Blink the caret
		if (mCaret != null && mNextBlink < RealTime.time)
		{
			mNextBlink = RealTime.time + 0.5f;
			mCaret.enabled = !mCaret.enabled;
		}

		// If the label's final alpha changes, we need to update the drawn geometry,
		// or the highlight widgets (which have their geometry set manually) won't update.
		if (isSelected && mLastAlpha != label.finalAlpha)
			UpdateLabel();

		// Cache the camera
		if (mCam == null) mCam = UICamera.FindCameraForLayer(gameObject.layer);

		// Having this in OnGUI causes issues because Input.inputString gets updated *after* OnGUI, apparently...
		if (mCam != null)
		{
			bool newLine = false;

			if (label.multiLine)
			{
				bool ctrl = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
				if (onReturnKey == OnReturnKey.Submit) newLine = ctrl;
				else newLine = !ctrl;
			}

			if (UICamera.GetKeyDown(mCam.submitKey0) || (mCam.submitKey0 == KeyCode.Return && UICamera.GetKeyDown(KeyCode.KeypadEnter)))
			{
				if (newLine)
				{
					Insert("\n");
				}
				else
				{
					if (UICamera.controller.current != null)
						UICamera.controller.clickNotification = UICamera.ClickNotification.None;
					UICamera.currentKey = mCam.submitKey0;
					Submit();
				}
			}

			if (UICamera.GetKeyDown(mCam.submitKey1) || (mCam.submitKey1 == KeyCode.Return && UICamera.GetKeyDown(KeyCode.KeypadEnter)))
			{
				if (newLine)
				{
					Insert("\n");
				}
				else
				{
					if (UICamera.controller.current != null)
						UICamera.controller.clickNotification = UICamera.ClickNotification.None;
					UICamera.currentKey = mCam.submitKey1;
					Submit();
				}
			}

			if (!mCam.useKeyboard && UICamera.GetKeyUp(KeyCode.Tab))
				OnKey(KeyCode.Tab);
		}
	}
Exemplo n.º 9
0
 protected virtual void Update()
 {
     //IL_00cb: Unknown result type (might be due to invalid IL or missing references)
     //IL_00d5: Unknown result type (might be due to invalid IL or missing references)
     //IL_00da: Unknown result type (might be due to invalid IL or missing references)
     //IL_00db: Unknown result type (might be due to invalid IL or missing references)
     //IL_00dd: Invalid comparison between Unknown and I4
     //IL_00e2: Unknown result type (might be due to invalid IL or missing references)
     //IL_00e5: Invalid comparison between Unknown and I4
     //IL_00ea: Unknown result type (might be due to invalid IL or missing references)
     //IL_00ed: Invalid comparison between Unknown and I4
     //IL_00f2: Unknown result type (might be due to invalid IL or missing references)
     //IL_00f5: Invalid comparison between Unknown and I4
     //IL_00fa: Unknown result type (might be due to invalid IL or missing references)
     //IL_00fd: Invalid comparison between Unknown and I4
     //IL_0102: Unknown result type (might be due to invalid IL or missing references)
     //IL_0105: Invalid comparison between Unknown and I4
     //IL_010a: Unknown result type (might be due to invalid IL or missing references)
     //IL_010d: Invalid comparison between Unknown and I4
     //IL_0129: Unknown result type (might be due to invalid IL or missing references)
     //IL_0148: Unknown result type (might be due to invalid IL or missing references)
     //IL_016d: Unknown result type (might be due to invalid IL or missing references)
     //IL_0194: Unknown result type (might be due to invalid IL or missing references)
     //IL_0198: Unknown result type (might be due to invalid IL or missing references)
     //IL_01a3: Unknown result type (might be due to invalid IL or missing references)
     //IL_01df: Unknown result type (might be due to invalid IL or missing references)
     //IL_01e4: Expected O, but got Unknown
     //IL_022e: Unknown result type (might be due to invalid IL or missing references)
     //IL_0233: Unknown result type (might be due to invalid IL or missing references)
     //IL_024e: Unknown result type (might be due to invalid IL or missing references)
     //IL_0253: Unknown result type (might be due to invalid IL or missing references)
     //IL_0258: Unknown result type (might be due to invalid IL or missing references)
     //IL_0274: Unknown result type (might be due to invalid IL or missing references)
     //IL_053c: Unknown result type (might be due to invalid IL or missing references)
     //IL_056c: Unknown result type (might be due to invalid IL or missing references)
     //IL_061f: Unknown result type (might be due to invalid IL or missing references)
     //IL_063a: Unknown result type (might be due to invalid IL or missing references)
     //IL_06ed: Unknown result type (might be due to invalid IL or missing references)
     if (isSelected && mSelectTime != Time.get_frameCount())
     {
         if (mDoInit)
         {
             Init();
         }
         if (mWaitForKeyboard)
         {
             if (mKeyboard != null && !mKeyboard.get_active())
             {
                 return;
             }
             mWaitForKeyboard = false;
         }
         if (mSelectMe != -1 && mSelectMe != Time.get_frameCount())
         {
             mSelectMe       = -1;
             mSelectionEnd   = ((!string.IsNullOrEmpty(mValue)) ? mValue.Length : 0);
             mDrawStart      = 0;
             mSelectionStart = ((!selectAllTextOnFocus) ? mSelectionEnd : 0);
             label.color     = activeTextColor;
             RuntimePlatform platform = Application.get_platform();
             if ((int)platform == 8 || (int)platform == 11 || (int)platform == 21 || (int)platform == 22 || (int)platform == 20 || (int)platform == 19 || (int)platform == 18)
             {
                 TouchScreenKeyboardType val;
                 string text;
                 if (inputShouldBeHidden)
                 {
                     TouchScreenKeyboard.set_hideInput(true);
                     val  = keyboardType;
                     text = "|";
                 }
                 else if (inputType == InputType.Password)
                 {
                     TouchScreenKeyboard.set_hideInput(false);
                     val             = 0;
                     text            = mValue;
                     mSelectionStart = mSelectionEnd;
                 }
                 else
                 {
                     TouchScreenKeyboard.set_hideInput(false);
                     val             = keyboardType;
                     text            = mValue;
                     mSelectionStart = mSelectionEnd;
                 }
                 mWaitForKeyboard = true;
                 mKeyboard        = ((inputType != InputType.Password) ? TouchScreenKeyboard.Open(text, val, !inputShouldBeHidden && inputType == InputType.AutoCorrect, label.multiLine && !hideInput, false, false, defaultText) : TouchScreenKeyboard.Open(text, val, false, false, true));
             }
             else
             {
                 Vector2 compositionCursorPos = Vector2.op_Implicit((!(UICamera.current != null) || !(UICamera.current.cachedCamera != null)) ? label.worldCorners[0] : UICamera.current.cachedCamera.WorldToScreenPoint(label.worldCorners[0]));
                 compositionCursorPos.y = (float)Screen.get_height() - compositionCursorPos.y;
                 Input.set_imeCompositionMode(1);
                 Input.set_compositionCursorPos(compositionCursorPos);
             }
             UpdateLabel();
             if (string.IsNullOrEmpty(Input.get_inputString()))
             {
                 return;
             }
         }
         if (mKeyboard != null)
         {
             string text2 = (!mKeyboard.get_done() && mKeyboard.get_active()) ? mKeyboard.get_text() : mCached;
             if (inputShouldBeHidden)
             {
                 if (text2 != "|")
                 {
                     if (!string.IsNullOrEmpty(text2))
                     {
                         Insert(text2.Substring(1));
                     }
                     else
                     {
                         DoBackspace();
                     }
                     mKeyboard.set_text("|");
                 }
             }
             else if (mCached != text2)
             {
                 mCached = text2;
                 if (!mKeyboard.get_done() && mKeyboard.get_active())
                 {
                     value = text2;
                 }
             }
             if (mKeyboard.get_done() || !mKeyboard.get_active())
             {
                 if (!mKeyboard.get_wasCanceled())
                 {
                     Submit();
                 }
                 mKeyboard  = null;
                 isSelected = false;
                 mCached    = string.Empty;
             }
         }
         else
         {
             string compositionString = Input.get_compositionString();
             if (string.IsNullOrEmpty(compositionString) && !string.IsNullOrEmpty(Input.get_inputString()))
             {
                 string inputString = Input.get_inputString();
                 for (int i = 0; i < inputString.Length; i++)
                 {
                     char c = inputString[i];
                     if (c >= ' ' && c != '\uf700' && c != '\uf701' && c != '\uf702' && c != '\uf703')
                     {
                         Insert(c.ToString());
                     }
                 }
             }
             if (mLastIME != compositionString)
             {
                 mSelectionEnd = ((!string.IsNullOrEmpty(compositionString)) ? (mValue.Length + compositionString.Length) : mSelectionStart);
                 mLastIME      = compositionString;
                 UpdateLabel();
                 ExecuteOnChange();
             }
         }
         if (mCaret != null && mNextBlink < RealTime.time)
         {
             mNextBlink = RealTime.time + 0.5f;
             mCaret.set_enabled(!mCaret.get_enabled());
         }
         if (isSelected && mLastAlpha != label.finalAlpha)
         {
             UpdateLabel();
         }
         if (mCam == null)
         {
             mCam = UICamera.FindCameraForLayer(this.get_gameObject().get_layer());
         }
         if (mCam != null)
         {
             if (UICamera.GetKeyDown(mCam.submitKey0))
             {
                 if (onReturnKey == OnReturnKey.NewLine || (onReturnKey == OnReturnKey.Default && label.multiLine && !Input.GetKey(306) && !Input.GetKey(305) && label.overflowMethod != UILabel.Overflow.ClampContent && validation == Validation.None))
                 {
                     Insert("\n");
                 }
                 else
                 {
                     if (UICamera.controller.current != null)
                     {
                         UICamera.controller.clickNotification = UICamera.ClickNotification.None;
                     }
                     UICamera.currentKey = mCam.submitKey0;
                     Submit();
                 }
             }
             if (UICamera.GetKeyDown(mCam.submitKey1))
             {
                 if (onReturnKey == OnReturnKey.NewLine || (onReturnKey == OnReturnKey.Default && label.multiLine && !Input.GetKey(306) && !Input.GetKey(305) && label.overflowMethod != UILabel.Overflow.ClampContent && validation == Validation.None))
                 {
                     Insert("\n");
                 }
                 else
                 {
                     if (UICamera.controller.current != null)
                     {
                         UICamera.controller.clickNotification = UICamera.ClickNotification.None;
                     }
                     UICamera.currentKey = mCam.submitKey1;
                     Submit();
                 }
             }
             if (!mCam.useKeyboard && UICamera.GetKeyUp(9))
             {
                 OnKey(9);
             }
         }
     }
 }