/// <summary> /// Register the specified iListener in the adequate list to be processed on every touch event. /// </summary> /// <param name='listener'> /// The object you are registering. Needed for callback invocations. /// </param> /// <param name='touchPhases'> /// All the touch phases you want your gameobject be registered to. /// </param> public void register(ITouchListener listener, params TouchPhase[] touchPhases) { #if TOUCH_EVENT_MANAGER_NO_QUADTREE for (int i = 0, c = touchPhases.Length; i < c; ++i) { dynamicListeners.add(listener, touchPhases[i]); } #else if (!listener.isScreenStatic()) { for (int i = 0, c = touchPhases.Length; i < c; ++i) { dynamicListeners.add(listener, touchPhases[i]); } } else { /// adding the listener's screen rect into the quad tree will return a list of /// as much as 4 ListenerLists elems, since the listener can fall in more than one quadrant Rect screenBounds = listener.getScreenBoundsAA(); ListenerLists[] leaves = staticQuadTree.add(screenBounds); for (int i = 0, c = leaves.Length; i < c; ++i) { // first listenerList element being not valid means next ones are also invalid if (leaves[i] == null) { break; } for (int j = 0, d = touchPhases.Length; j < d; ++j) { leaves[i].add(listener, touchPhases[j]); } } } #endif }
/// <summary> /// Register the specified iListener in the adequate list to be processed on every touch event. /// </summary> /// <param name='listener'> /// The object you are registering. Needed for callback invocations. /// </param> /// <param name='touchPhases'> /// All the touch phases you want your gameobject be registered to. /// </param> public void register(ITouchListener listener, params TouchPhase[] touchPhases) { if (!listener.isStatic()) { dynamicListeners.add(listener, touchPhases); } else { /// adding the listener's screen rect into the quad tree will return a list of /// as much as 4 ListenerLists elems, since the listener can fall in more than one quadrant ListenerLists[] leaves = staticQuadTree.add(listener.getScreenBoundsAA()); for (int i = 0, c = leaves.Length; i < c; ++i) { // first listenerList element being not valid means next ones are also invalid if (leaves[i] == null) { break; } leaves[i].add(listener, touchPhases); } } }