コード例 #1
0
        public void DrawGizmos(Graphic graphic)
        {
            CanvasGraphicGroup group = FindGraphicGroup(graphic);

            if (group != null)
            {
                UnitMeshInfo rendermesh = group.mesh;
                if (rendermesh != null && rendermesh.getTexture() != null)
                {
                    Gizmos.color = Color.red;
                    int vertcnt = rendermesh.VertCnt();
                    int uvcnt   = rendermesh.UVCnt();
                    if (vertcnt != uvcnt)
                    {
                        Debug.LogError("data error");
                    }
                    else
                    {
                        for (int i = 0; i < vertcnt; i += 4)
                        {
                            Vector3 p1 = getPoint(graphic, rendermesh.GetVert(i));
                            Vector3 p2 = getPoint(graphic, rendermesh.GetVert(i + 1));
                            Vector3 p3 = getPoint(graphic, rendermesh.GetVert(i + 2));
                            Vector3 p4 = getPoint(graphic, rendermesh.GetVert(i + 3));

                            Gizmos.DrawLine(p1, p2);
                            Gizmos.DrawLine(p2, p3);
                            Gizmos.DrawLine(p3, p4);
                            Gizmos.DrawLine(p4, p1);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public void FillMesh(Graphic graphic, VertexHelper vh)
        {
            CanvasGraphicGroup group = FindGraphicGroup(graphic);

            if (group != null)
            {
                UnitMeshInfo rendermesh = group.mesh;
                if (rendermesh != null && rendermesh.getTexture() != null)
                {
                    int vertcnt = rendermesh.VertCnt();
                    int uvcnt   = rendermesh.UVCnt();
                    if (vertcnt != uvcnt)
                    {
                        Debug.LogError("data error");
                    }
                    else
                    {
                        for (int i = 0; i < vertcnt; ++i)
                        {
                            vh.AddVert(rendermesh.GetVert(i), graphic.color, rendermesh.GetUV(i));
                        }

                        int cnt = vertcnt / 4;
                        for (int i = 0; i < cnt; ++i)
                        {
                            int m = i * 4;

                            vh.AddTriangle(m, m + 1, m + 2);
                            vh.AddTriangle(m + 2, m + 3, m);
                        }

                        //vh.AddTriangle(0, 1, 2);
                        //vh.AddTriangle(2, 3, 0);
                    }
                }
            }
        }