コード例 #1
0
        void RefreshSubUIMesh(InlineText text, SpriteGraphic target, SpriteAsset matchAsset, Vector3[] Pos, Vector2[] UV)
        {
            // set mesh
            tempMesh.SetAtlas(matchAsset);
            tempMesh.SetUVLen(UV.Length);
            tempMesh.SetVertLen(Pos.Length);

            for (int i = 0; i < Pos.Length; ++i)
            {
                //text object pos
                Vector3 value    = Pos[i];
                Vector3 worldpos = text.transform.TransformPoint(value);
                Vector3 localpos = target.transform.InverseTransformPoint(worldpos);
                tempMesh.SetVert(i, localpos);
            }

            for (int i = 0; i < UV.Length; ++i)
            {
                Vector2 value = UV[i];
                tempMesh.SetUV(i, value);
            }

            //rendermesh
            UnitMeshInfo currentMesh = null;

            if (!this.renderData.TryGetValue(target, out currentMesh))
            {
                currentMesh        = new UnitMeshInfo();
                renderData[target] = currentMesh;
            }

            if (!currentMesh.Equals(tempMesh))
            {
                if (target.isDirty)
                {
                    currentMesh.AddCopy(tempMesh);
                    tempMesh.Clear();
                }
                else
                {
                    currentMesh.Copy(tempMesh);
                }
            }

            if (currentMesh.VertCnt() > 3 && currentMesh.UVCnt() > 3)
            {
                target.Draw(this);
                target.SetDirtyMask();
                target.SetVerticesDirty();
            }
            else
            {
                target.Draw(null);
                target.SetDirtyMask();
                target.SetVerticesDirty();
            }
        }
コード例 #2
0
        void RefreshSubUIMesh(InlineText text, CanvasGraphicGroup group, SpriteAsset matchAsset, Vector3[] Pos, Vector2[] UV, List <string> joblist)
        {
            // set mesh
            tempMesh.SetAtlas(matchAsset);
            tempMesh.SetUVLen(UV.Length);
            tempMesh.SetVertLen(Pos.Length);

            SpriteGraphic graphic = group.graphic;

            //think about culling and screen coordinate.......
            for (int i = 0; i < Pos.Length; ++i)
            {
                //text object pos
                Vector3 value    = Pos[i];
                Vector3 worldpos = text.transform.TransformPoint(value);
                Vector3 localpos = group.graphic.transform.InverseTransformPoint(worldpos);
                tempMesh.SetVert(i, localpos);
            }

            for (int i = 0; i < UV.Length; ++i)
            {
                Vector2 value = UV[i];
                tempMesh.SetUV(i, value);
            }

            //rendermesh
            UnitMeshInfo currentMesh = group.mesh;

            if (!currentMesh.Equals(tempMesh))
            {
                if (joblist != null && joblist.Count > 0)
                {
                    currentMesh.AddCopy(tempMesh);
                    tempMesh.Clear();
                }
                else
                {
                    currentMesh.Copy(tempMesh);
                }
            }

            if (currentMesh.VertCnt() > 3 && currentMesh.UVCnt() > 3)
            {
                graphic.Draw(this);
            }
            else
            {
                graphic.Draw(null);
            }

            group.isDirty = true;
        }