Esempio n. 1
0
    public void OnRenderObject()
    {
        if (Camera.current != Camera.main)
        {
            return;
        }

        Max2D.SetLineWidth(0.25f);
        Max2D.SetColor(Color.black);
        Max2D.SetBorder(false);
        Max2D.SetLineMode(Max2D.LineMode.Smooth);

        inspectorPosition = Vector3.zero;

        Vector2D pos = new Vector2D(Camera.main.ScreenToWorldPoint(Input.mousePosition));

        foreach (Slicer2D slicer in Slicer2D.GetList())
        {
            Polygon2D poly = slicer.GetPolygon().ToWorldSpace(slicer.transform);
            if (poly.PointInPoly(pos))
            {
                Rect rect = poly.GetBounds();

                Max2D.DrawLineRectf(rect.x, rect.y, rect.width, rect.height);
                Max2D.DrawLinef(rect.center.x, rect.center.y, rect.center.x, rect.center.y + rect.height / 2 + 1);

                inspectorPosition = new Vector2(rect.center.x, rect.center.y + rect.height / 2);

                originalSize = slicer.GetComponent <Slicer2DInspectorTracker>().originalSize;
                currentSize  = poly.GetArea();
                sliced       = slicer.sliceCounter;
            }
        }
    }