Esempio n. 1
0
        public override void RebuildVertex(VertexHelper vh)
        {
            if (fadePatternData == null)
            {
                return;
            }

            vh.Clear();

            var r       = Target.GetPixelAdjustedRect();
            var color32 = Target.color;

            DicingImage targetDicing = Target as DicingImage;

            float scaleX = r.width / fadePatternData.Width;
            float scaleY = r.height / fadePatternData.Height;
            int   index  = 0;

            List <DicingTextureData.QuadVerts> defaultVerts = targetDicing.GetVerts(targetDicing.PatternData);
            List <DicingTextureData.QuadVerts> fadeVerts    = targetDicing.GetVerts(fadePatternData);

            int count = defaultVerts.Count;

            if (count != fadeVerts.Count)
            {
                count = Mathf.Min(count, fadeVerts.Count);
                Debug.LogError(string.Format("Not equal texture size {0} and {1}", targetDicing.PatternData.Name, fadePatternData.Name));
            }

            for (int i = 0; i < count; ++i)
            {
                var vert0 = defaultVerts[i];
                var vert1 = fadeVerts[i];

                if (targetDicing.SkipTransParentCell && vert0.isAllTransparent && vert1.isAllTransparent)
                {
                    continue;
                }

                Vector4 v = new Vector4(
                    r.x + scaleX * vert0.v.x,
                    r.y + scaleY * vert0.v.y,
                    r.x + scaleX * vert0.v.z,
                    r.y + scaleY * vert0.v.w
                    );
                Rect uvRect0 = vert0.uvRect;
                Rect uvRect1 = vert1.uvRect;

                vh.AddVert(new Vector3(v.x, v.y), color32, new Vector2(uvRect0.xMin, uvRect0.yMin), new Vector2(uvRect1.xMin, uvRect1.yMin), Vector3.zero, Vector4.zero);
                vh.AddVert(new Vector3(v.x, v.w), color32, new Vector2(uvRect0.xMin, uvRect0.yMax), new Vector2(uvRect1.xMin, uvRect1.yMax), Vector3.zero, Vector4.zero);
                vh.AddVert(new Vector3(v.z, v.w), color32, new Vector2(uvRect0.xMax, uvRect0.yMax), new Vector2(uvRect1.xMax, uvRect1.yMax), Vector3.zero, Vector4.zero);
                vh.AddVert(new Vector3(v.z, v.y), color32, new Vector2(uvRect0.xMax, uvRect0.yMin), new Vector2(uvRect1.xMax, uvRect1.yMin), Vector3.zero, Vector4.zero);

                vh.AddTriangle(index + 0, index + 1, index + 2);
                vh.AddTriangle(index + 2, index + 3, index + 0);
                index += 4;
            }
        }
 public override void RebuildVertex(VertexHelper vh)
 {
     if (this.fadePatternData != null)
     {
         vh.Clear();
         Rect        pixelAdjustedRect = this.Target.GetPixelAdjustedRect();
         Color       color             = this.Target.get_color();
         DicingImage target            = this.Target as DicingImage;
         float       num  = pixelAdjustedRect.get_width() / ((float)this.fadePatternData.Width);
         float       num2 = pixelAdjustedRect.get_height() / ((float)this.fadePatternData.Height);
         int         num3 = 0;
         List <DicingTextureData.QuadVerts> list  = target.GetVerts(target.PatternData);
         List <DicingTextureData.QuadVerts> list2 = target.GetVerts(this.fadePatternData);
         int count = list.Count;
         if (count != list2.Count)
         {
             count = Mathf.Min(count, list2.Count);
             Debug.LogError(string.Format("Not equal texture size {0} and {1}", target.PatternData.Name, this.fadePatternData.Name));
         }
         for (int i = 0; i < count; i++)
         {
             DicingTextureData.QuadVerts verts  = list[i];
             DicingTextureData.QuadVerts verts2 = list2[i];
             if ((!target.SkipTransParentCell || !verts.isAllTransparent) || !verts2.isAllTransparent)
             {
                 Vector4 vector       = new Vector4(pixelAdjustedRect.get_x() + (num * verts.v.x), pixelAdjustedRect.get_y() + (num2 * verts.v.y), pixelAdjustedRect.get_x() + (num * verts.v.z), pixelAdjustedRect.get_y() + (num2 * verts.v.w));
                 Rect    uvRect       = verts.uvRect;
                 Rect    rect3        = verts2.uvRect;
                 float   introduced15 = uvRect.get_xMin();
                 float   introduced16 = rect3.get_xMin();
                 vh.AddVert(new Vector3(vector.x, vector.y), color, new Vector2(introduced15, uvRect.get_yMin()), new Vector2(introduced16, rect3.get_yMin()), Vector3.get_zero(), Vector4.get_zero());
                 float introduced17 = uvRect.get_xMin();
                 float introduced18 = rect3.get_xMin();
                 vh.AddVert(new Vector3(vector.x, vector.w), color, new Vector2(introduced17, uvRect.get_yMax()), new Vector2(introduced18, rect3.get_yMax()), Vector3.get_zero(), Vector4.get_zero());
                 float introduced19 = uvRect.get_xMax();
                 float introduced20 = rect3.get_xMax();
                 vh.AddVert(new Vector3(vector.z, vector.w), color, new Vector2(introduced19, uvRect.get_yMax()), new Vector2(introduced20, rect3.get_yMax()), Vector3.get_zero(), Vector4.get_zero());
                 float introduced21 = uvRect.get_xMax();
                 float introduced22 = rect3.get_xMax();
                 vh.AddVert(new Vector3(vector.z, vector.y), color, new Vector2(introduced21, uvRect.get_yMin()), new Vector2(introduced22, rect3.get_yMin()), Vector3.get_zero(), Vector4.get_zero());
                 vh.AddTriangle(num3, num3 + 1, num3 + 2);
                 vh.AddTriangle(num3 + 2, num3 + 3, num3);
                 num3 += 4;
             }
         }
     }
 }