Пример #1
0
    private void CreateGustures()
    {
#if (UNITY_ANDROID || UNITY_IPHONE) && !UNITY_EDITOR
        if (Application.isPlaying && InputManager.Instance == null)
        {
            Debug.LogWarning("You must place an instance of InputManager in scene to make JoyElementResizer works correctly");
        }
#endif

        if (InputManager.Instance != null)
        {
            if (_ScaleDetector == null)
            {
                _ScaleDetector = new ScaleGestureDetector()
                {
                    FingerCount = 2, LockTouches = true, Priority = ((uint)Elements.Length + 1)
                };
                _ScaleDetector.Scale += _ScaleDetector_Scale;
                InputManager.Add(_ScaleDetector);
            }
            if (_DragDetector == null)
            {
                _DragDetector = new DragGestureDetector()
                {
                    FingerCount = 1, LockTouches = true, IsEnabled = false
                };
                InputManager.Add(_DragDetector);
                _DragDetector.Drag += JoyElementResizer_Drag;
            }

            if (_TapDetector == null)
            {
                _TapDetector = new TapGestureDetector()
                {
                    FingerCount = 1, LockTouches = false
                };
                InputManager.Add(_TapDetector);
                _TapDetector.Tap += JoyElementResizer_Tap;
            }
        }
    }
Пример #2
0
    protected override void OnDestroy()
    {
        if (InputManager.Instance != null)
        {
            if (_ScaleDetector != null)
            {
                InputManager.Remove(_ScaleDetector);
                _ScaleDetector = null;
            }
            if (_DragDetector != null)
            {
                InputManager.Remove(_DragDetector);
                _DragDetector = null;
            }
            if (_TapDetector != null)
            {
                InputManager.Remove(_TapDetector);
                _TapDetector = null;
            }
        }

        base.OnDestroy();
    }