public static void OpenTestWindow() { VectorShapeEditor testWindow = EditorWindow.GetWindow(typeof(VectorShapeEditor)) as VectorShapeEditor; testWindow.titleContent.text = "Testing..."; PointShape testPoint = new PointShape(-2, 0); testPoint.colorOutline = Color.black; PolyShape testLine = new PolyShape(new Vector2(-1, 0), 0.4f, 4); testLine.colorOutline = Color.black; for (int i = 0; i < testLine.vertices.Length; i++) { testLine.vertices[i].segmentCurves = true; } testLine.closed = false; CircleShape testCircle = new CircleShape(new Vector2(0, 0), 0.4f); testCircle.colorOutline = Color.black; PolyShape testPoly3 = new PolyShape(new Vector2(1, 2), 0.45f, 3); testPoly3.colorOutline = Color.black; PolyShape testPoly4 = new PolyShape(new Vector2(1, 1), 0.50f, 4); testPoly4.colorOutline = Color.black; testPoly4.RotateAround(new Vector2(1, 1), 45); PolyShape testPoly5 = new PolyShape(new Vector2(1, 0), 0.45f, 5); testPoly5.colorOutline = Color.black; PolyShape testPoly6 = new PolyShape(new Vector2(1, -1), 0.45f, 6); testPoly6.colorOutline = Color.black; testPoly6.RotateAround(new Vector2(1, -1), 30); PolyShape testShape = new PolyShape(new Vector2(2, 0), 0.4f, 4); testShape.colorOutline = Color.black; for (int i = 0; i < testShape.vertices.Length; i++) { testShape.vertices[i].segmentCurves = true; } testWindow.backgroundColor = Color.white; testWindow.Shapes = new List <VectorShape>() { testPoint, testLine, testCircle, testPoly3, testPoly4, testPoly5, testPoly6, testShape }; //testWindow.Selection = new List<VectorShape>() { testLine, testShape, testPoly5 }; testWindow.Focus(); }
public static void OpenEditor(SerializedShape shape) { VectorShapeEditor editorWindow = EditorWindow.GetWindow(typeof(VectorShapeEditor)) as VectorShapeEditor; if (editorWindow.OnCheckSave()) { editorWindow.targetShape = shape; editorWindow.titleContent.text = shape.name; editorWindow.Shapes = shape.components; editorWindow.Focus(); } }
public static void OpenTestWindow() { VectorShapeEditor testWindow = EditorWindow.GetWindow(typeof(VectorShapeEditor)) as VectorShapeEditor; testWindow.titleContent.text = "New Shape"; EllipseShape testEllipse = new EllipseShape(Vector2.one, 1f, 2f, 22.5f); testEllipse.colorOutline = Color.green; PolyShape testRect = new PolyShape(testEllipse.ShapeBounds); testWindow.Shapes = new List <VectorShape>() { testEllipse, testRect }; testWindow.Focus(); }
public static void OpenTestWindow() { VectorShapeEditor testWindow = EditorWindow.GetWindow(typeof(VectorShapeEditor)) as VectorShapeEditor; testWindow.titleContent.text = "Testing..."; /* * * PointShape testPoint = new PointShape(-2, 0); * testPoint.colorOutline = Color.black; * * PolyShape testLine = new PolyShape(new Vector2(-1, 0), 0.4f, 4); * testLine.colorOutline = Color.black; * for (int i = 0; i < testLine.vertices.Length; i++) * { * testLine.vertices[i].segmentCurves = true; * } * testLine.closed = false; * * CircleShape testCircle = new CircleShape(new Vector2(0, 0), 0.4f); * testCircle.colorOutline = Color.black; * * PolyShape testPoly3 = new PolyShape(new Vector2(1, 2), 0.45f, 3); * testPoly3.colorOutline = Color.black; * PolyShape testPoly4 = new PolyShape(new Vector2(1, 1), 0.50f, 4); * testPoly4.colorOutline = Color.black; * testPoly4.RotateAround(new Vector2(1, 1), 45); * PolyShape testPoly5 = new PolyShape(new Vector2(1, 0), 0.45f, 5); * testPoly5.colorOutline = Color.black; * PolyShape testPoly6 = new PolyShape(new Vector2(1, -1), 0.45f, 6); * testPoly6.colorOutline = Color.black; * testPoly6.RotateAround(new Vector2(1, -1), 30); * * PolyShape testShape = new PolyShape(new Vector2(2, 0), 0.4f, 4); * testShape.colorOutline = Color.black; * for (int i = 0; i < testShape.vertices.Length; i++) * { * testShape.vertices[i].segmentCurves = true; * } * * testWindow.Shapes = new List<VectorShape>() { testPoint, testLine, testCircle, testPoly3, testPoly4, testPoly5, testPoly6, testShape }; * testWindow.Focus(); * * string tempPath = Application.dataPath + "/test.svg"; * System.IO.Stream stream = new System.IO.FileStream(tempPath, System.IO.FileMode.OpenOrCreate); * VectorShapeSVGExporter exporter = new VectorShapeSVGExporter(); * Rect bounds = new Rect(-5, -5, 10, 10); * exporter.Open(stream, bounds, VectorShapeSVGExporter.Unit.Centimeters); * exporter.AddShapeGroup(testWindow.Shapes, "TestGroup"); * exporter.Close(); * stream.Close(); */ //EllipseShape testEllipse = new EllipseShape(Vector2.zero, 1f, 2f, 22.5f); //testEllipse.colorOutline = Color.green; //PolyShape testRect = new PolyShape(testEllipse.ShapeBounds); //testWindow.Shapes = new List<VectorShape>() { testEllipse, testRect }; //TextAsset asset = Resources.Load("Flipper_Left_SVG") as TextAsset; //testWindow.Shapes = VectorShapeFilesSVG.ReadSVG(new System.IO.StringReader(asset.text)); //TextAsset asset = Resources.Load("InlineDrop_DXF") as TextAsset; //TextAsset asset = Resources.Load("Saucer_DXF") as TextAsset; //TextAsset asset = Resources.Load("LaneGuide_1500_DXF") as TextAsset; TextAsset asset = Resources.Load("Playfield_DXF") as TextAsset; //TextAsset asset = Resources.Load("ThreeTarget_DXF") as TextAsset; testWindow.Shapes = VectorShapeFilesDXF.ReadDXF(new System.IO.MemoryStream(asset.bytes)); testWindow.Focus(); }