Assets/Watson/Scripts/Utilities/TouchEventManager.cs
/// <summary>
/// Unregisters the double tap event.
/// </summary>
/// <returns><c>true</c>, if double tap event was unregistered, <c>false</c> otherwise.</returns>
/// <param name="gameObjectToTouch">Game object to touch.</param>
/// <param name="callback">Callback.</param>
/// <param name="SortingLayer">Sorting layer.</param>
/// <param name="isDoubleTapInside">If set to <c>true</c> is double tap inside.</param>
/// <param name="layerMask">Layer mask.</param>
Unregisters the double tap event.
Unregisters the double tap event .
public bool UnregisterDoubleTapEvent(GameObject gameObjectToTouch, string callback, int SortingLayer = 0, bool isDoubleTapInside = true, LayerMask layerMask = default(LayerMask))
        {
            bool success = false;
            if (gameObjectToTouch != null)
            {
                if (!string.IsNullOrEmpty(callback))
                {
                    int layerMaskAsKey = (layerMask != default(LayerMask)) ? layerMask.value : (1 << gameObjectToTouch.layer);
                    if (m_DoubleTapEvents.ContainsKey(layerMaskAsKey))
                    {
                        success = true;
                        Collider[] colliderList = gameObjectToTouch.GetComponentsInChildren<Collider>(includeInactive: true);
                        if (colliderList != null && colliderList.Length > 0)
                        {
                            foreach (Collider itemCollider in colliderList)
                            {
                                int numberOfRemovedCallbacks = m_DoubleTapEvents[layerMaskAsKey].RemoveAll(
                                    e => 
                                    e.Collider == itemCollider && 
                                    e.TapCallback == callback  &&
                                    e.SortingLayer == SortingLayer &&
                                    e.IsInside == isDoubleTapInside);
                                success &= (numberOfRemovedCallbacks > 0);
                            }
                        }
                        else
                        {
                            success = false;
                        }
                        if (!success)
                        {
                            success = true;
                            Collider2D[] colliderList2D = gameObjectToTouch.GetComponentsInChildren<Collider2D>(includeInactive: true);
                            if (colliderList2D != null && colliderList2D.Length > 0)
                            {
                                foreach (Collider2D itemCollider2D in colliderList2D)
                                {
                                    int numberOfRemovedCallbacks = m_DoubleTapEvents[layerMaskAsKey].RemoveAll(
                                        e => 
                                        e.Collider2D == itemCollider2D && 
                                        e.TapCallback == callback  &&
                                        e.SortingLayer == SortingLayer &&
                                        e.IsInside == isDoubleTapInside);
                                    success &= (numberOfRemovedCallbacks > 0);
                                }
                            }
                            else
                            {
                                success = false;
                            }
                        }
                        #if UNITY_4_6 || UNITY_5 || UNITY_5_3_OR_NEWER
                        if (!success)
                        {
                            success = true;
                            RectTransform[] rectTransformList = gameObjectToTouch.GetComponentsInChildren<RectTransform> (includeInactive: true);
                            if (rectTransformList != null && rectTransformList.Length > 0)
                            {
                                foreach (RectTransform itemRectTransform in rectTransformList)
                                {
                                    int numberOfRemovedCallbacks = m_DoubleTapEvents[layerMaskAsKey].RemoveAll(
                                        e => 
                                        e.RectTransform == itemRectTransform && 
                                        e.TapCallback == callback  &&
                                        e.SortingLayer == SortingLayer &&
                                        e.IsInside == isDoubleTapInside);
                                    success &= (numberOfRemovedCallbacks > 0);
                                }
                            }
                            else
                            {
                                success = false;
                            }
                        }
                        #endif
                    }
                }
                else
                {
                    Log.Warning("TouchEventManager", "There is no callback for double-tap event unregistration");
                }
            }
            else
            {
                Log.Warning("TouchEventManager", "There is no gameobject for double-tap event unregistration");
            }
            return success;
        }
public bool UnregisterDoubleTapEvent ( GameObject gameObjectToTouch , string callback , int SortingLayer = 0 , bool isDoubleTapInside = true , LayerMask layerMask = default ( LayerMask ) ) { bool success = false ; if ( gameObjectToTouch != null ) { if ( ! string . IsNullOrEmpty ( callback ) ) { int layerMaskAsKey = ( layerMask != default ( LayerMask ) ) ? layerMask . value : ( 1 << gameObjectToTouch . layer ) ; if ( m_DoubleTapEvents . ContainsKey ( layerMaskAsKey ) ) { success = true ; Collider [ ] colliderList = gameObjectToTouch . GetComponentsInChildren < Collider > ( includeInactive : true ) ; if ( colliderList != null && colliderList . Length > 0 ) { foreach ( Collider itemCollider in colliderList ) { int numberOfRemovedCallbacks = m_DoubleTapEvents [ layerMaskAsKey ] . RemoveAll ( e => e . Collider == itemCollider && e . TapCallback == callback && e . SortingLayer == SortingLayer && e . IsInside == isDoubleTapInside ) ; success &= ( numberOfRemovedCallbacks > 0 ) ; } } else { success = false ; } if ( ! success ) { success = true ; Collider2D [ ] colliderList2D = gameObjectToTouch . GetComponentsInChildren < Collider2D > ( includeInactive : true ) ; if ( colliderList2D != null && colliderList2D . Length > 0 ) { foreach ( Collider2D itemCollider2D in colliderList2D ) { int numberOfRemovedCallbacks = m_DoubleTapEvents [ layerMaskAsKey ] . RemoveAll ( e => e . Collider2D == itemCollider2D && e . TapCallback == callback && e . SortingLayer == SortingLayer && e . IsInside == isDoubleTapInside ) ; success &= ( numberOfRemovedCallbacks > 0 ) ; } } else { success = false ; } } if UNITY_4_6 || UNITY_5 || UNITY_5_3_OR_NEWER if ( ! success ) { success = true ; RectTransform [ ] rectTransformList = gameObjectToTouch . GetComponentsInChildren < RectTransform > ( includeInactive : true ) ; if ( rectTransformList != null && rectTransformList . Length > 0 ) { foreach ( RectTransform itemRectTransform in rectTransformList ) { int numberOfRemovedCallbacks = m_DoubleTapEvents [ layerMaskAsKey ] . RemoveAll ( e => e . RectTransform == itemRectTransform && e . TapCallback == callback && e . SortingLayer == SortingLayer && e . IsInside == isDoubleTapInside ) ; success &= ( numberOfRemovedCallbacks > 0 ) ; } } else { success = false ; } } endif } } else { Log . Warning ( " " , " " ) ; } } else { Log . Warning ( " " , " " ) ; } return success ; }
Unregisters the double tap event.
Unregisters the double tap event .
None
gameObjectToTouch
GameObject
Game object to touch.
Game object to touch .
callback
string
None
SortingLayer
int
None
isDoubleTapInside
bool
If set to true
If set to true
layerMask
LayerMask
None