Esempio n. 1
0
        private void CreateNewPolygon()
        {
            var newPolygon = new PolygonWithExtraInfo();

            simplePolygons.Add(newPolygon);
            int index = simplePolygons.Count - 1;

            newPolygon.name      = $"Polygon {(simplePolygons.Count - 1):d2}";
            ctrl.polygonSelected = index;
        }
Esempio n. 2
0
        private void DrawPolygonsInScene()
        {
            Color backup = Handles.color;

            for (int i = 0; i < simplePolygons.Count; i++)
            {
                PolygonWithExtraInfo polyEx = simplePolygons[i];
                PolygonSimple        poly   = polyEx.polygon;
                bool polygonSelected        = i == ctrl.polygonSelected;
                bool polygonHover           = i == ctrl.polygonHover;

                for (int j = 0; j < poly.verts.Count; j++)
                {
                    Vector3 thisPoint = poly.verts[j].ToV3();
                    Vector3 nextPoint = poly.verts[(j + 1) % poly.verts.Count].ToV3();
                    if (j == ctrl.lineSelected && polygonHover)
                    {
                        Handles.color = colorSelected;
                        Handles.DrawLine(thisPoint, nextPoint);
                    }
                    else
                    {
                        Handles.color = polygonSelected ? colorActive : colorInactive;
                        Handles.DrawDottedLine(thisPoint, nextPoint, 4f);
                    }

                    if (j == ctrl.pointSelected && polygonHover)
                    {
                        Handles.color = colorSelected;
                    }
                    else
                    {
                        Handles.color = polygonSelected ? colorActive : colorInactive;
                    }
                    Handles.DrawSolidDisc(thisPoint, Vector3.up, ctrl.selectDistance);
                }
            }

            Handles.color = backup;
            sceneDirty    = false;
        }