public bool ShouldReceiveTouch(TouchLayer layer, TouchPoint touch)
        {
            if (layer == RenderTextureLayer)
#pragma warning disable 252,253
                return touch.InputSource == Source;
#pragma warning restore 252,253
#pragma warning disable 252,253
            return touch.InputSource != Source;
#pragma warning restore 252,253
        }
    bool ContainsLayer(TouchScript.Layers.TouchLayer layer)
    {
        for (int i = 0; i < layerManager.LayerCount; i++)
        {
            if (layerManager.Layers[i].GetInstanceID() == layerUI.GetInstanceID())
            {
                return(true);
            }
        }

        return(false);
    }
 /// <inheritdoc />
 public bool AddLayer(TouchLayer layer, int index)
 {
     if (layer == null) return false;
     if (index >= layers.Count) return AddLayer(layer);
     var i = layers.IndexOf(layer);
     if (i == -1)
     {
         layers.Insert(index, layer);
     } else
     {
         if (index == i || i == index - 1) return true;
         layers.RemoveAt(i);
         if (index < i) layers.Insert(index, layer);
         else layers.Insert(index - 1, layer);
     }
     return true;
 }
 /// <inheritdoc />
 public bool AddLayer(TouchLayer layer)
 {
     if (layer == null) return false;
     if (layers.Contains(layer)) return true;
     layers.Add(layer);
     return true;
 }
Beispiel #5
0
 public bool ShouldReceiveTouch(TouchLayer layer, TouchPoint touch)
 {
     if (layer == RenderTextureLayer)
         return touch.InputSource == Source;
     return touch.InputSource != Source;
 }
Beispiel #6
0
 /// <summary>
 /// Called to reset gesture state after it fails or recognizes.
 /// </summary>
 protected virtual void reset()
 {
     layer = null;
     cachedScreenPosition = TouchManager.INVALID_POSITION;
     cachedPreviousScreenPosition = TouchManager.INVALID_POSITION;
 }
 /// <inheritdoc />
 public bool RemoveLayer(TouchLayer layer)
 {
     if (layer == null) return false;
     var result = layers.Remove(layer);
     if (result) layerCount--;
     return result;
 }
        /// <inheritdoc />
        public bool AddLayer(TouchLayer layer, int index = -1, bool addIfExists = true)
        {
            if (layer == null) return false;

            var i = layers.IndexOf(layer);
            if (i != -1)
            {
                if (!addIfExists) return false;
                layers.RemoveAt(i);
                layerCount--;
            }
            if (index == 0)
            {
                layers.Insert(0, layer);
                layerCount++;
                return i == -1;
            }
            if (index == -1 || index >= layerCount)
            {
                layers.Add(layer);
                layerCount++;
                return i == -1;
            }
            if (i != -1)
            {
                if (index < i) layers.Insert(index, layer);
                else layers.Insert(index - 1, layer);
                layerCount++;
                return false;
            }
            layers.Insert(index, layer);
            layerCount++;
            return true;
        }
Beispiel #9
0
        /// <summary>
        /// Checks if the touch has hit something.
        /// </summary>
        /// <param name="touch">The touch.</param>
        /// <param name="hit">Output RaycastHit.</param>
        /// <param name="hitCamera">Output camera which was used to hit an object.</param>
        /// <returns>Object's transform which has been hit or null otherwise.</returns>
        public bool GetHitTarget(Vector2 position, out RaycastHit hit, out TouchLayer layer)
        {
            hit = new RaycastHit();
            layer = null;

            foreach (var touchLayer in layers)
            {
                if (touchLayer == null) continue;
                RaycastHit _hit;
                if (touchLayer.Hit(position, out _hit) == HitResult.Hit)
                {
                    hit = _hit;
                    layer = touchLayer;
                    return true;
                }
            }

            return false;
        }
 /// <inheritdoc />
 public bool AddLayer(TouchLayer layer, int index)
 {
     if (layer == null) return false;
     if (index >= layers.Count) return AddLayer(layer);
     var i = layers.IndexOf(layer);
     if (i == -1)
     {
         layers.Insert(index, layer);
         layer.OrderIndexChanged += layerOrderIndexChanged;
     }
     else
     {
         if (index == i || i == index - 1) return true;
         layers.RemoveAt(i);
         if (index < i) layers.Insert(index, layer);
         else layers.Insert(index - 1, layer);
     }
     layersOrderedCacheDirty = true;
     return true;
 }
 /// <inheritdoc />
 public bool AddLayer(TouchLayer layer)
 {
     if (layer == null) return false;
     if (layers.Contains(layer)) return true;
     layers.Add(layer);
     layer.OrderIndexChanged += layerOrderIndexChanged;
     layersOrderedCacheDirty = true;
     return true;
 }
 /// <inheritdoc />
 public bool AddLayer(TouchLayer layer)
 {
     return AddLayer(layer, 0);
 }
        /// <inheritdoc />
        protected override void touchesBegan(IList<ITouch> touches)
        {
            base.touchesMoved(touches);

            if (touches.Count == activeTouches.Count)
            {
                projectionLayer = activeTouches[0].Layer;
                updateProjectionPlane();
            }
        }
        /// <inheritdoc />
        protected override void touchesBegan(IList<ITouch> touches)
        {
            base.touchesBegan(touches);

            if (State != GestureState.Possible) return;
            if (touches.Count == NumTouches)
            {
                projectionLayer = activeTouches[0].Layer;
                updateProjectionPlane();
            }
        }
Beispiel #15
0
        internal void INTERNAL_TouchesBegan(IList<TouchPoint> touches)
        {
            if (numTouches == 0) layer = touches[0].Layer;

            var count = touches.Count;
            var total = numTouches + count;
            touchesNumState = TouchesNumState.InRange;

            if (minTouches <= 0)
            {
                // minTouches is not set and we got our first touches
                if (numTouches == 0) touchesNumState = TouchesNumState.PassedMinThreshold;
            }
            else
            {
                if (numTouches < minTouches)
                {
                    // had < minTouches, got >= minTouches
                    if (total >= minTouches) touchesNumState = TouchesNumState.PassedMinThreshold;
                    else touchesNumState = TouchesNumState.TooFew;
                }
            }

            if (maxTouches > 0)
            {
                if (numTouches <= maxTouches)
                {
                    if (total > maxTouches)
                    {
                        // this event we crossed both minTouches and maxTouches
                        if (touchesNumState == TouchesNumState.PassedMinThreshold) touchesNumState = TouchesNumState.PassedMinMaxThreshold;
                        // this event we crossed maxTouches
                        else touchesNumState = TouchesNumState.PassedMaxThreshold;
                    }
                }
                // last event we already were over maxTouches
                else touchesNumState = TouchesNumState.TooMany;
            }

            if (state == GestureState.Began || state == GestureState.Changed)
            {
                for (var i = 0; i < count; i++) touches[i].INTERNAL_Retain();
            }

            activeTouches.AddRange(touches);
            numTouches = total;
            touchesBegan(touches);
        }
Beispiel #16
0
 public static bool AddLayer(TouchLayer layer)
 {
     if (shuttingDown) return false;
     if (layer == null) return false;
     if (Instance == null) return false;
     if (Instance.layers.Contains(layer)) return false;
     Instance.layers.Add(layer);
     return true;
 }
Beispiel #17
0
 public static bool RemoveLayer(TouchLayer layer)
 {
     if (shuttingDown) return false;
     if (layer == null) return false;
     if (instance == null) return false;
     var result = instance.layers.Remove(layer);
     return result;
 }
        /// <inheritdoc />
        public bool GetHitTarget(Vector2 position, out ITouchHit hit, out TouchLayer layer)
        {
            hit = null;
            layer = null;

            var count = layersOrdered.Count;
            for (var i = 0; i < count; i++)
            {
                var touchLayer = layersOrdered[i];
                if (touchLayer == null) continue;
                ITouchHit _hit;
                if (touchLayer.Hit(position, out _hit) == TouchLayer.LayerHitResult.Hit)
                {
                    hit = _hit;
                    layer = touchLayer;
                    return true;
                }
            }

            return false;
        }
        /// <inheritdoc />
        protected override void touchBegan(TouchPoint touch)
        {
            base.touchBegan(touch);

            if (State != GestureState.Possible) return;
            if (NumTouches == 1)
            {
                projectionLayer = activeTouches[0].Layer;
                updateProjectionPlane();
            }
        }
 /// <inheritdoc />
 public bool RemoveLayer(TouchLayer layer)
 {
     if (layer == null) return false;
     var result = layers.Remove(layer);
     if (result)
         layer.OrderIndexChanged -= layerOrderIndexChanged;
     layersOrderedCacheDirty = true;
     return result;
 }
        /// <inheritdoc />
        public bool GetHitTarget(Vector2 position, out TouchHit hit, out TouchLayer layer)
        {
            hit = default(TouchHit);
            layer = null;

            for (var i = 0; i < layerCount; i++)
            {
                var touchLayer = layers[i];
                if (touchLayer == null) continue;
                TouchHit _hit;
                if (touchLayer.Hit(position, out _hit) == TouchLayer.LayerHitResult.Hit)
                {
                    hit = _hit;
                    layer = touchLayer;
                    return true;
                }
            }

            return false;
        }
 private void layerOrderIndexChanged(TouchLayer layer, int index)
 {
     layersOrderedCacheDirty = true;
 }
Beispiel #23
0
        internal void INTERNAL_TouchBegan(TouchPoint touch)
        {
            if (numTouches == 0) layer = touch.Layer;

            var total = numTouches + 1;
            touchesNumState = TouchesNumState.InRange;

            if (minTouches <= 0)
            {
                // minTouches is not set and we got our first touches
                if (numTouches == 0) touchesNumState = TouchesNumState.PassedMinThreshold;
            }
            else
            {
                if (numTouches < minTouches)
                {
                    // had < minTouches, got >= minTouches
                    if (total >= minTouches) touchesNumState = TouchesNumState.PassedMinThreshold;
                    else touchesNumState = TouchesNumState.TooFew;
                }
            }

            if (maxTouches > 0)
            {
                if (numTouches <= maxTouches)
                {
                    if (total > maxTouches)
                    {
                        // this event we crossed both minTouches and maxTouches
                        if (touchesNumState == TouchesNumState.PassedMinThreshold) touchesNumState = TouchesNumState.PassedMinMaxThreshold;
                        // this event we crossed maxTouches
                        else touchesNumState = TouchesNumState.PassedMaxThreshold;
                    }
                }
                // last event we already were over maxTouches
                else touchesNumState = TouchesNumState.TooMany;
            }

            if (state == GestureState.Began || state == GestureState.Changed) touch.INTERNAL_Retain();

            activeTouches.Add(touch);
            numTouches = total;
            touchBegan(touch);
        }
        /// <inheritdoc />
        protected override void touchesBegan(IList<ITouch> touches)
        {
            base.touchesBegan(touches);

            if (touchesNumState == TouchesNumState.PassedMaxThreshold ||
                touchesNumState == TouchesNumState.PassedMinMaxThreshold)
            {
                switch (State)
                {
                    case GestureState.Began:
                    case GestureState.Changed:
                        setState(GestureState.Ended);
                        break;
                    case GestureState.Possible:
                        setState(GestureState.Failed);
                        break;
                }
            } else if (touches.Count == NumTouches)
            {
                projectionLayer = activeTouches[0].Layer;
                updateProjectionPlane();
            }
        }
        /// <inheritdoc />
        protected override void touchBegan(TouchPoint touch)
        {
            base.touchBegan(touch);

            if (State != GestureState.Possible) return;
            if (NumTouches == 1)
            {
                projectionLayer = activeTouches[0].Layer;
                updateProjectionPlane();

#if TOUCHSCRIPT_DEBUG
                drawDebug(activeTouches[0].ProjectionParams.ProjectFrom(cachedTransform.position), activeTouches[0].Position);
#endif
            }
        }
        /// <inheritdoc />
        protected override void touchesBegan(IList<ITouch> touches)
        {
            base.touchesBegan(touches);

            if (State != GestureState.Possible) return;
            if (touches.Count == NumTouches)
            {
                projectionLayer = activeTouches[0].Layer;
                updateProjectionPlane();

            #if DEBUG
                drawDebug(projectionLayer.ProjectFrom(cachedTransform.position), activeTouches[0].Position);
            #endif
            }
        }