Esempio n. 1
0
        protected virtual void DoResizing(MouseEventArgs e)
        {
            if (isResizing)
            {
                if (e.CheckButtonsPressed(MouseButtons.Left))
                {
                    e.Handled = true;

                    Ray   ray   = e.Ray;
                    float enter = 0.0f;

                    Plane detectionPlane = new Plane(windowPanel.GetUIView().uiCamera.transform.TransformDirection(Vector3.back), this.cachedLastPosition);
                    detectionPlane.Raycast(ray, out enter);

                    Vector3 mousePositionW = VectorExtensions.Quantize(ray.origin + ray.direction * enter, windowPanel.PixelsToUnits());

                    Vector3 transformVecToTopLeftW = UIPivotExtensions.TransformToUpperLeft((UIPivotPoint)windowPanel.Pivot, windowPanel.Size, windowPanel.ArbitaryPivotOffset);

                    Vector3 point1S = windowPanel.GameObject.transform.position + transformVecToTopLeftW;

                    Vector2 newSize = (mousePositionW - point1S) / windowPanel.PixelsToUnits();
                    newSize = new Vector2(newSize.x, -newSize.y);

                    if (newSize.x < this.windowPanel.MinSize.x)
                    {
                        newSize.x = this.windowPanel.MinSize.x;
                    }
                    else if (newSize.x > this.windowPanel.MaxSize.x)
                    {
                        newSize.x = this.windowPanel.MaxSize.x;
                    }
                    if (newSize.y < this.windowPanel.MinSize.y)
                    {
                        newSize.y = this.windowPanel.MinSize.y;
                    }
                    else if (newSize.y > this.windowPanel.MaxSize.y)
                    {
                        newSize.y = this.windowPanel.MaxSize.y;
                    }

                    windowPanel.Size = newSize;

                    this.cachedLastPosition = mousePositionW;

                    this.OnResizing();
                }
                else
                {
                    StopResizing();
                }
            }
        }