public void OnDrag(PointerEventData eventData) { if (Input.GetMouseButton(2)) { return; } if (_selfElement == null) { _selfElement = GlobalData.GetElement(transform.name); } Vector2 pos = Utils.GetAnchoredPositionInContainer(Input.mousePosition) - _offset; Vector2 offset = pos - selfRect.anchoredPosition; DisplayObjectUtil.UpdateElementPosition(selfRect, _selfElement, pos); UlEventSystem.DispatchTrigger <UIEventType>(UIEventType.UpdateInspectorInfo); _alignInfo = DisplayObjectUtil.GetAlignLine(_selfElement, _alignInfo); if (_alignInfo?.HorizontalAlignLine != null) { Rectangle horizontalAlignRect = _alignInfo.HorizontalAlignLine; print($"_alignInfo.HorizontalAlignType: {_alignInfo.HorizontalAlignType}, isCenter: {_alignInfo.HorizontalAlignType == AlignType.HorizontalCenter}"); _horizontalAlignLineManager.gameObject.SetActive(true); _horizontalAlignLineManager.transform.SetAsLastSibling(); AlignType leftType = _alignInfo.HorizontalAlignType; AlignType rightType = _alignInfo.OtherHorizontalAlignType; if (Math.Abs(_alignInfo.HorizontalAlignLine.Right - _selfElement.Right) < Math.Abs(_alignInfo.HorizontalAlignLine.Left - _selfElement.Left)) { leftType = _alignInfo.OtherHorizontalAlignType; rightType = _alignInfo.HorizontalAlignType; } _horizontalAlignLineManager.UpdateHorizontal(leftType, rightType, Element.InvConvertTo(new Vector2(horizontalAlignRect.X - GlobalData.AlignExtensionValue, horizontalAlignRect.Y)), new Vector2(horizontalAlignRect.Width + (GlobalData.AlignExtensionValue << 1), horizontalAlignRect.Height)); } else { _horizontalAlignLineManager.gameObject.SetActive(false); } if (_alignInfo?.VerticalAlignLine != null) { Rectangle verticalAlignRect = _alignInfo.VerticalAlignLine; print($"_alignInfo.VerticalAlignType: {_alignInfo.VerticalAlignType}, isCenter: {_alignInfo.VerticalAlignType == AlignType.VerticalCenter}"); _verticalAlignLineManager.gameObject.SetActive(true); _verticalAlignLineManager.transform.SetAsLastSibling(); AlignType upType = _alignInfo.VerticalAlignType; AlignType downType = _alignInfo.OtherVerticalAlignType; if (Math.Abs(_alignInfo.VerticalAlignLine.Top - _selfElement.Top) < Math.Abs(_alignInfo.VerticalAlignLine.Bottom - _selfElement.Bottom)) { upType = _alignInfo.OtherVerticalAlignType; downType = _alignInfo.VerticalAlignType; } _verticalAlignLineManager.UpdateVertical(upType, downType, Element.InvConvertTo(new Vector2(verticalAlignRect.X, verticalAlignRect.Y - GlobalData.AlignExtensionValue)), new Vector2(verticalAlignRect.Width, verticalAlignRect.Height + (GlobalData.AlignExtensionValue << 1))); } else { _verticalAlignLineManager.gameObject.SetActive(false); } if (GlobalData.CurrentSelectDisplayObjectDic.Count == 1) { return; } foreach (var pair in GlobalData.CurrentSelectDisplayObjectDic) { if (pair.Value == transform) { continue; } RectTransform rt = pair.Value.GetComponent <RectTransform>(); DisplayObjectUtil.UpdateElementPosition(rt, pair.Key, rt.anchoredPosition + offset); } }