Beispiel #1
0
        public override bool Process()
        {
            if (!Input.GetMouseButton(0))
            {
                return(false);
            }

            var newX = GuiStage.MousePosition.X - MousePosInComponent.X;
            var newY = GuiStage.MousePosition.Y - MousePosInComponent.Y;

            if (SnapToParent)
            {
                newX = Mathf.Max(0, Mathf.Min(newX, GuiElement.GetParent().GetLayout().GetCalculatedWidth() - GuiElement.GetLayout().GetCalculatedWidth()));
                newY = Mathf.Max(0, Mathf.Min(newY, GuiElement.GetParent().GetLayout().GetCalculatedHeight() - GuiElement.GetLayout().GetCalculatedHeight()));
            }

            GuiElement.X = newX;
            GuiElement.Y = newY;

            return(true);
        }