コード例 #1
0
        // Start is called before the first frame update
        void Start()
        {
            Unity.Mathematics.float3x4 verticies =
                GetComponentInParent <IMRE.ScaleDimension.CrossSections.SquareCrossSection>().squareVertices;
            LineRenderer lr = gameObject.AddComponent <LineRenderer>();

            lr.positionCount = 4;
            lr.SetPositions(new Vector3[] { verticies.c0, verticies.c1, verticies.c2, verticies.c3 });

            lr.useWorldSpace = true;
            lr.startWidth    = 0.01f;
            lr.endWidth      = 0.01f;
            lr.loop          = true;

            lr.material = mat;
        }
コード例 #2
0
        // Start is called before the first frame update
        void Start()
        {
            Unity.Mathematics.float3x4 vertices =
                GetComponentInParent <IMRE.ScaleDimension.CrossSections.TetrahedronCrossSection>().tetrahderonVertices;
            Mesh mesh = new Mesh();

            mesh.vertices = new Vector3[] { vertices.c0, vertices.c1, vertices.c2, vertices.c3 };

            int[] tris =
            {
                0, 1, 2,
                0, 2, 3,
                0, 3, 1,
                1, 2, 3
            };

            mesh.triangles = tris;
            mesh.RecalculateNormals();

            gameObject.AddComponent <MeshFilter>();
            gameObject.AddComponent <MeshRenderer>();
            GetComponent <MeshFilter>().mesh       = mesh;
            GetComponent <MeshRenderer>().material = mat;
        }