コード例 #1
0
    public static void DrawPoint(TestCoordinates position, float width, Color colour)
    {
        GameObject   line         = new GameObject("Point: " + position.ToString());
        LineRenderer lineRenderer = line.AddComponent <LineRenderer>();

        lineRenderer.material       = new Material(Shader.Find("Unlit/Color"));
        lineRenderer.material.color = colour;
        lineRenderer.positionCount  = 2;
        lineRenderer.SetPosition(0, new Vector3(position.x - width / 3.0f, position.y - width / 3.0f, position.z));
        lineRenderer.SetPosition(1, new Vector3(position.x + width / 3.0f, position.y + width / 3.0f, position.z));
        lineRenderer.startWidth = width;
        lineRenderer.endWidth   = width;
    }
コード例 #2
0
    public static void DrawLine(TestCoordinates startPoint, TestCoordinates endPosition, float width, Color colour)
    {
        GameObject   line         = new GameObject("Line: " + startPoint.ToString() + " _ " + endPosition.ToString());
        LineRenderer lineRenderer = line.AddComponent <LineRenderer>();

        lineRenderer.material       = new Material(Shader.Find("Unlit/Color"));
        lineRenderer.material.color = colour;
        lineRenderer.positionCount  = 2;
        lineRenderer.SetPosition(0, new Vector3(startPoint.x, startPoint.y, startPoint.z));
        lineRenderer.SetPosition(1, new Vector3(endPosition.x, endPosition.y, endPosition.z));
        lineRenderer.startWidth = width;
        lineRenderer.endWidth   = width;
    }
コード例 #3
0
    // Start is called before the first frame update
    void Start()
    {
        p.ToString();
        TestCoordinates.DrawPoint(new TestCoordinates(5, 50, -1), 5, Color.yellow);
        TestCoordinates.DrawPoint(new TestCoordinates(100, 0, -1), 5, Color.blue);

        TestCoordinates.DrawLine(startPointY, endPointY, 3, Color.green);
        TestCoordinates.DrawLine(startPointX, endPointX, 3, Color.red);


        foreach (TestCoordinates tc in points)
        {
            TestCoordinates.DrawPoint(tc, 5, Color.gray);
        }

        TestCoordinates.DrawLine(points[0], points[1], 3, Color.white);
        TestCoordinates.DrawLine(points[1], points[2], 3, Color.white);
    }
コード例 #4
0
    void DrawGraph()
    {
        TestCoordinates startPositionX = new TestCoordinates(-xmax, 0, 0);
        TestCoordinates endPositionX   = new TestCoordinates(xmax, 0, 0);

        TestCoordinates startPositionY = new TestCoordinates(0, -ymax, 0);
        TestCoordinates endPositionY   = new TestCoordinates(0, ymax, 0);

        //TestCoordinates.DrawLine(startPositionX, endPositionX, 1, Color.white);

        //TestCoordinates.DrawLine(startPositionY, endPositionY, 1, Color.white);


        int xoffset = (int)(xmax / size);

        int yoffset = (int)(ymax / size);

        //for (int x = -xmax; x <= xmax; x += (int)size)
        //{
        //    TestCoordinates.DrawLine(new TestCoordinates(x, -ymax, 0), new TestCoordinates(x, ymax, 0), 1, Color.white);
        //}

        //for (int y = -ymax; y <= ymax; y += (int)size)
        //{
        //    TestCoordinates.DrawLine(new TestCoordinates(-xmax, y, 0), new TestCoordinates(xmax, y, 0), 1, Color.white);
        //}

        for (int x = -xoffset * (int)size; x <= xmax; x += (int)size)
        {
            TestCoordinates.DrawLine(new TestCoordinates(x, -ymax, 0), new TestCoordinates(x, ymax, 0), 1, Color.white);
        }

        for (int y = -yoffset * (int)size; y <= ymax; y += (int)size)
        {
            TestCoordinates.DrawLine(new TestCoordinates(-xmax, y, 0), new TestCoordinates(xmax, y, 0), 1, Color.white);
        }
    }