예제 #1
0
        private void OnDragEnd(PointerEventData eventData)
        {
            if (!_selectedObject)
            {
                return;
            }

            _selectedObject.Drag(eventData);
            _selectedObject.UnSelect();
            _selectedObject = null;
        }
예제 #2
0
        private void OnDragBegin(PointerEventData eventData)
        {
            var ray = _camera.ScreenPointToRay(eventData.position);

            if (!CheckHitTarget(ray, out var hitTarget))
            {
                return;
            }

            _selectedObject = hitTarget;
            _selectedObject.Select();
            _selectedObject.Drag(eventData);
        }
예제 #3
0
        /// <summary>
        /// Get the hit target
        /// </summary>
        private bool CheckHitTarget(Ray ray, out RaycastableObject hitTarget)
        {
            for (var i = 0; i < _targetColliders.Length; ++i)
            {
                if (!_targetColliders[i].Raycast(ray, out var hitInfo, 20))
                {
                    continue;
                }

                hitTarget = _targets[i];
                return(true);
            }

            hitTarget = null;
            return(false);
        }