示例#1
0
        /// <inheritdoc />
        protected override void touchesBegan(IList <ITouch> touches)
        {
            base.touchesBegan(touches);

            if (State == GestureState.Possible)
            {
                setState(GestureState.Began);
            }

            var length = touches.Count;

            if (touchBeganInvoker != null)
            {
                for (var i = 0; i < length; i++)
                {
                    touchBeganInvoker.InvokeHandleExceptions(this, new MetaGestureEventArgs(touches[i]));
                }
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                for (var i = 0; i < length; i++)
                {
                    SendMessageTarget.SendMessage(TOUCH_BEGAN_MESSAGE, touches[i], SendMessageOptions.DontRequireReceiver);
                }
            }
        }
        /// <inheritdoc />
        protected override void pointersUpdated(IList <Pointer> pointers)
        {
#if UNITY_5_6_OR_NEWER
            gestureSampler.Begin();
#endif

            base.pointersUpdated(pointers);

            if (State == GestureState.Began || State == GestureState.Changed)
            {
                setState(GestureState.Changed);
            }

            var length = pointers.Count;
            if (pointerUpdatedInvoker != null)
            {
                for (var i = 0; i < length; i++)
                {
                    pointerUpdatedInvoker.InvokeHandleExceptions(this, new MetaGestureEventArgs(pointers[i]));
                }
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                for (var i = 0; i < length; i++)
                {
                    SendMessageTarget.SendMessage(POINTER_MOVED_MESSAGE, pointers[i], SendMessageOptions.DontRequireReceiver);
                }
            }

#if UNITY_5_6_OR_NEWER
            gestureSampler.End();
#endif
        }
示例#3
0
        /// <inheritdoc />
        protected override void touchesEnded(IList <ITouch> touches)
        {
            base.touchesEnded(touches);

            if ((State == GestureState.Began || State == GestureState.Changed) && NumTouches == 0)
            {
                setState(GestureState.Ended);
            }

            var length = touches.Count;

            if (touchEndedInvoker != null)
            {
                for (var i = 0; i < length; i++)
                {
                    touchEndedInvoker.InvokeHandleExceptions(this, new MetaGestureEventArgs(touches[i]));
                }
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                for (var i = 0; i < length; i++)
                {
                    SendMessageTarget.SendMessage(TOUCH_ENDED_MESSAGE, touches[i], SendMessageOptions.DontRequireReceiver);
                }
            }
        }
示例#4
0
        /// <inheritdoc />
        protected override void touchesCancelled(IList <ITouch> touches)
        {
            base.touchesCancelled(touches);

            if ((State == GestureState.Began || State == GestureState.Changed) && activeTouches.Count == 0)
            {
                setState(GestureState.Ended);
            }

            var length = touches.Count;

            if (touchCancelledInvoker != null)
            {
                for (var i = 0; i < length; i++)
                {
                    touchCancelledInvoker(this, new MetaGestureEventArgs(touches[i]));
                }
            }
            if (UseSendMessage)
            {
                for (var i = 0; i < length; i++)
                {
                    SendMessageTarget.SendMessage(TOUCH_CANCELLED_MESSAGE, touches[i], SendMessageOptions.DontRequireReceiver);
                }
            }
        }
    /// <summary>
    /// Sets the selected item (based on index)
    /// </summary>
    public void SetSelectedItem()
    {
        if (index < 0 || index >= ItemList.Count)
        {
            index = 0;
        }
        if (index >= 0 && index < ItemList.Count)
        {
            selectedTextMesh.text = ItemList[index];
            selectedTextMesh.Commit();
        }
        else
        {
            selectedTextMesh.text = "";
            selectedTextMesh.Commit();
        }

        if (OnSelectedItemChange != null)
        {
            OnSelectedItemChange();
        }

        if (SendMessageTarget != null && SendMessageOnSelectedItemChangeMethodName.Length > 0)
        {
            SendMessageTarget.SendMessage(SendMessageOnSelectedItemChangeMethodName, this, SendMessageOptions.RequireReceiver);
        }
    }
 private void TargetOnScrollCallback()
 {
     if (SendMessageTarget != null && SendMessageOnScrollMethodName.Length > 0)
     {
         SendMessageTarget.SendMessage(SendMessageOnScrollMethodName, this, SendMessageOptions.RequireReceiver);
     }
 }
示例#7
0
        /// <inheritdoc />
        protected override void pointersCancelled(IList <Pointer> pointers)
        {
            gestureSampler.Begin();

            base.pointersCancelled(pointers);

            var length = pointers.Count;

            if (pointerCancelledInvoker != null)
            {
                for (var i = 0; i < length; i++)
                {
                    pointerCancelledInvoker.InvokeHandleExceptions(this, new MetaGestureEventArgs(pointers[i]));
                }
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                for (var i = 0; i < length; i++)
                {
                    SendMessageTarget.SendMessage(POINTER_CANCELLED_MESSAGE, pointers[i], SendMessageOptions.DontRequireReceiver);
                }
            }

            gestureSampler.End();
        }
示例#8
0
        /// <inheritdoc />
        protected override void pointersReleased(IList <Pointer> pointers)
        {
            gestureSampler.Begin();

            base.pointersReleased(pointers);

            if ((State == GestureState.Began || State == GestureState.Changed) && NumPointers == 0)
            {
                setState(GestureState.Ended);
            }

            var length = pointers.Count;

            if (pointerReleasedInvoker != null)
            {
                for (var i = 0; i < length; i++)
                {
                    pointerReleasedInvoker.InvokeHandleExceptions(this, new MetaGestureEventArgs(pointers[i]));
                }
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                for (var i = 0; i < length; i++)
                {
                    SendMessageTarget.SendMessage(POINTER_RELEASED_MESSAGE, pointers[i], SendMessageOptions.DontRequireReceiver);
                }
            }

            gestureSampler.End();
        }
示例#9
0
    private void InputDeselected()
    {
        Debug.Log("gotcha");

        if (checkNum)
        {
            int Tnumber;

            if (int.TryParse(inputLabel.text, out Tnumber))
            {
                if (Tnumber > maxNum)
                {
                    Text = maxNum.ToString();
                }
                else if (Tnumber < minNum)
                {
                    if (Tnumber < 10)
                    {
                        Text = "0" + Tnumber;
                    }
                    else
                    {
                        Text = minNum.ToString();
                    }
                }

                else if (Tnumber < 10)
                {
                    Text = "0" + Tnumber;
                }
            }
            else
            {
                Debug.Log("this isnt a number");
                Text = "";
            }

            SendMessageTarget.SendMessage(SendMessageOnTextChangeMethodName, this, SendMessageOptions.RequireReceiver);
        }

        if (text.Length == 0)
        {
            ShowDisplayText();
        }
        isSelected = false;
        if (!useTouchScreenKeyboard && listenForKeyboardText)
        {
            tk2dUIManager.Instance.OnInputUpdate -= ListenForKeyboardTextUpdate;
        }
        listenForKeyboardText = false;
        SetState();
#if TOUCH_SCREEN_KEYBOARD
        if (keyboard != null && !keyboard.done)
        {
            keyboard.active = false;
        }
        keyboard = null;
#endif
    }
示例#10
0
 /// <inheritdoc />
 protected override void onChanged()
 {
     base.onChanged();
     scaledInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
     if (UseSendMessage && SendMessageTarget != null)
     {
         SendMessageTarget.SendMessage(SCALE_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
 }
示例#11
0
 /// <inheritdoc />
 protected override void onRecognized()
 {
     base.onRecognized();
     panCompletedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
     if (UseSendMessage && SendMessageTarget != null)
     {
         SendMessageTarget.SendMessage(PAN_COMPLETE_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
 }
示例#12
0
 /// <inheritdoc />
 protected override void onRecognized()
 {
     base.onRecognized();
     longPressedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
     if (UseSendMessage && SendMessageTarget != null)
     {
         SendMessageTarget.SendMessage(LONG_PRESS_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
 }
        protected override void onCancelled()
        {
            Debug.Log("In onCancelled()");
            base.onCancelled();

            if (UseSendMessage && SendMessageTarget != null)
            {
                SendMessageTarget.SendMessage("OnTouchUp", this, SendMessageOptions.DontRequireReceiver);
            }
        }
示例#14
0
        /// <inheritdoc />
        protected override void onRecognized()
        {
            base.onRecognized();

            StopCoroutine("wait");
            tappedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
            if (UseSendMessage && SendMessageTarget != null)
            {
                SendMessageTarget.SendMessage(TAP_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
            }
        }
示例#15
0
 void NotifyTextChange()
 {
     if (OnTextChange != null)
     {
         OnTextChange(this);
     }
     if (SendMessageTarget != null && SendMessageOnTextChangeMethodName.Length > 0)
     {
         SendMessageTarget.SendMessage(SendMessageOnTextChangeMethodName, this, SendMessageOptions.RequireReceiver);
     }
 }
示例#16
0
 /// <inheritdoc />
 protected override void onBegan()
 {
     base.onBegan();
     panStartedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
     pannedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
     if (UseSendMessage && SendMessageTarget != null)
     {
         SendMessageTarget.SendMessage(PAN_START_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
         SendMessageTarget.SendMessage(PAN_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
 }
 /// <inheritdoc />
 protected override void onBegan()
 {
     base.onBegan();
     if (transformStartedInvoker != null)
     {
         transformStartedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
     }
     if (UseSendMessage && SendMessageTarget != null)
     {
         SendMessageTarget.SendMessage(TRANSFORM_START_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
 }
 /// <inheritdoc />
 protected override void onRecognized()
 {
     base.onRecognized();
     if (rotateCompletedInvoker != null)
     {
         rotateCompletedInvoker(this, EventArgs.Empty);
     }
     if (UseSendMessage)
     {
         SendMessageTarget.SendMessage(ROTATE_COMPLETE_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
 }
示例#19
0
 /// <inheritdoc />
 protected override void onRecognized()
 {
     base.onRecognized();
     if (flickedInvoker != null)
     {
         flickedInvoker(this, EventArgs.Empty);
     }
     if (UseSendMessage)
     {
         SendMessageTarget.SendMessage(FLICK_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
 }
示例#20
0
 /// <inheritdoc />
 protected override void onRecognized()
 {
     base.onRecognized();
     if (pressedInvoker != null)
     {
         pressedInvoker(this, EventArgs.Empty);
     }
     if (UseSendMessage && SendMessageTarget != null)
     {
         SendMessageTarget.SendMessage(PRESS_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
 }
示例#21
0
 /// <inheritdoc />
 protected override void onChanged()
 {
     base.onChanged();
     if (pannedInvoker != null)
     {
         pannedInvoker(this, EventArgs.Empty);
     }
     if (UseSendMessage)
     {
         SendMessageTarget.SendMessage(PAN_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
 }
示例#22
0
 /// <inheritdoc />
 protected override void onCancelled()
 {
     base.onCancelled();
     if (PreviousState != GestureState.Possible)
     {
         panCompletedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
         if (UseSendMessage && SendMessageTarget != null)
         {
             SendMessageTarget.SendMessage(PAN_COMPLETE_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
         }
     }
 }
    private void ListenForKeyboardTextUpdate()
    {
        bool   change  = false;
        string newText = text;
        //http://docs.unity3d.com/Documentation/ScriptReference/Input-inputString.html

        string inputStr = Input.inputString;
        char   c;

        for (int i = 0; i < inputStr.Length; i++)
        {
            c = inputStr[i];
            if (c == "\b"[0])
            {
                if (text.Length != 0)
                {
                    newText = text.Substring(0, text.Length - 1);
                    change  = true;
                }
            }
            else if (c == "\n"[0] || c == "\r"[0])
            {
            }
            else if ((int)c != 9 && (int)c != 27) //deal with a Mac only Unity bug where it returns a char for escape and tab
            {
                newText += c;
                change   = true;
            }
        }

#if UNITY_IOS && !UNITY_EDITOR
        inputStr = keyboard.text;
        if (!inputStr.Equals(text))
        {
            newText = inputStr;
            change  = true;
        }
#endif
        if (change)
        {
            Text = newText;
            if (OnTextChange != null)
            {
                OnTextChange(this);
            }

            if (SendMessageTarget != null && SendMessageOnTextChangeMethodName.Length > 0)
            {
                SendMessageTarget.SendMessage(SendMessageOnTextChangeMethodName, this, SendMessageOptions.RequireReceiver);
            }
        }
    }
示例#24
0
        /// <inheritdoc />
        protected override void touchCancelled(TouchPoint touch)
        {
            base.touchCancelled(touch);

            if (touchCancelledInvoker != null)
            {
                touchCancelledInvoker.InvokeHandleExceptions(this, new MetaGestureEventArgs(touch));
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                SendMessageTarget.SendMessage(TOUCH_CANCELLED_MESSAGE, touch, SendMessageOptions.DontRequireReceiver);
            }
        }
 /// <inheritdoc />
 protected override void onCancelled()
 {
     base.onCancelled();
     if (PreviousState != GestureState.Possible)
     {
         if (rotateCompletedInvoker != null)
         {
             rotateCompletedInvoker(this, EventArgs.Empty);
         }
         if (UseSendMessage)
         {
             SendMessageTarget.SendMessage(ROTATE_COMPLETE_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
         }
     }
 }
示例#26
0
 /// <inheritdoc />
 protected override void onRecognized()
 {
     base.onRecognized();
     if (releasedInvoker != null)
     {
         releasedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
     }
     if (UseSendMessage && SendMessageTarget != null)
     {
         SendMessageTarget.SendMessage(RELEASE_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
     if (UseUnityEvents)
     {
         OnRelease.Invoke(this);
     }
 }
        /// <inheritdoc />
        protected override void onRecognized()
        {
            base.onRecognized();

            // need to clear moved touches updateMoved() wouldn't fire in a wrong state
            // yes, if moved and released the same frame movement data will be lost
            movedTouches.Clear();
            if (transformCompletedInvoker != null)
            {
                transformCompletedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                SendMessageTarget.SendMessage(TRANSFORM_COMPLETE_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
            }
        }
 /// <inheritdoc />
 protected override void onBegan()
 {
     base.onBegan();
     if (rotateStartedInvoker != null)
     {
         rotateStartedInvoker(this, EventArgs.Empty);
     }
     if (rotatedInvoker != null)
     {
         rotatedInvoker(this, EventArgs.Empty);
     }
     if (UseSendMessage)
     {
         SendMessageTarget.SendMessage(ROTATE_START_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
         SendMessageTarget.SendMessage(ROTATE_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
 }
示例#29
0
        /// <inheritdoc />
        protected override void onRecognized()
        {
            base.onRecognized();

            if (transformCompletedInvoker != null)
            {
                transformCompletedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                SendMessageTarget.SendMessage(TRANSFORM_COMPLETE_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
            }
            if (UseUnityEvents)
            {
                OnTransformComplete.Invoke(this);
            }
        }
示例#30
0
        /// <inheritdoc />
        protected override void touchBegan(TouchPoint touch)
        {
            base.touchBegan(touch);

            if (State == GestureState.Possible)
            {
                setState(GestureState.Began);
            }

            if (touchBeganInvoker != null)
            {
                touchBeganInvoker.InvokeHandleExceptions(this, new MetaGestureEventArgs(touch));
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                SendMessageTarget.SendMessage(TOUCH_BEGAN_MESSAGE, touch, SendMessageOptions.DontRequireReceiver);
            }
        }