private void CreateSegment(LockButton button)
        {
            var lastIndex = _lineSegments.Count + 1;
            var segment   = new GameObject($"Segment_{lastIndex}");

            var rectTransform = segment.AddComponent <RectTransform>();
            var image         = segment.AddComponent <Image>();

            var delta = rectTransform.sizeDelta;

            _lineSegments.Add(rectTransform);
            _currentSequence.Add(button);

            image.raycastTarget = false;

            segment.transform.parent = _lineRoot;

            delta.y = _currentSequence.First().InnerCircleRectTransform.sizeDelta.y
                      *_canvas.scaleFactor;

            delta.x = delta.y;

            rectTransform.sizeDelta = delta;

            rectTransform.anchoredPosition
                = button.InnerCircleRectTransform.position;

            lastIndex++;
        }
 private void OnButtonPointerDown(PointerEventData data, LockButton button)
 {
     if (!_isHold)
     {
         ResetColors();
         CreateSegment(button);
     }
     _isHold = true;
 }
 private void OnButtonPointerEnter(PointerEventData data, LockButton button)
 {
     if (!_isHold)
     {
         return;
     }
     if (_currentSequence.Contains(button))
     {
         return;
     }
     if (_currentSequence.Any())
     {
         UpdateLine(button.InnerCircleRectTransform.position);
     }
     CreateSegment(button);
 }
        private void OnButtonPointerUp(PointerEventData data, LockButton button)
        {
            var lastSegment = _lineSegments.Last();

            if (lastSegment != null)
            {
                _lineSegments.RemoveAt(_lineSegments.Count - 1);

                Destroy(lastSegment.gameObject);
            }
            _isHold = false;

            CheckLock();

            DoReset();
        }