Beispiel #1
0
        public override void ModifyMesh(VertexHelper vh)
        {
            if (!IsActive())
            {
                return;
            }
            List <UIVertex> verts = TypePool <List <UIVertex> > .Get();

            vh.GetUIVertexStream(verts);

            var neededCpacity = verts.Count * 9;

            if (verts.Capacity < neededCpacity)
            {
                verts.Capacity = neededCpacity;
            }

            var start = 0;
            var end   = verts.Count;

            ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, effectDistance.x, effectDistance.y);

            start = end;
            end   = verts.Count;
            ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, effectDistance.x, -effectDistance.y);

            start = end;
            end   = verts.Count;
            ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, -effectDistance.x, effectDistance.y);

            start = end;
            end   = verts.Count;
            ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, -effectDistance.x, -effectDistance.y);

            start = end;
            end   = verts.Count;
            ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, -effectDistance.x, 0);

            start = end;
            end   = verts.Count;
            ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, effectDistance.x, 0);

            start = end;
            end   = verts.Count;
            ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, 0, -effectDistance.y);

            start = end;
            end   = verts.Count;
            ApplyShadowZeroAlloc(verts, effectColor, start, verts.Count, 0, effectDistance.y);

            vh.Clear();
            vh.AddUIVertexTriangleStream(verts);
            verts.Clear();
            TypePool <List <UIVertex> > .Put(verts);
        }
Beispiel #2
0
    public override void ModifyMesh(VertexHelper vh)
    {
        if (!IsActive())
        {
            return;
        }

        List <UIVertex> output = TypePool <List <UIVertex> > .Get();

        vh.GetUIVertexStream(output);



        int count = output.Count;

        if (count > 0)
        {
            float bottomY = output[0].position.y;
            float topY    = output[0].position.y;

            for (int i = 1; i < count; i++)
            {
                float y = output[i].position.y;
                if (y > topY)
                {
                    topY = y;
                }
                else if (y < bottomY)
                {
                    bottomY = y;
                }
            }
            UIVertex v;
            float    uiElementHeight = topY - bottomY;
            for (int i = 0; i < count; i++)
            {
                v = output[i];

                if (!m_UseGraphicAlpha && !m_UseRGB)
                {
                    v.color = Color32.Lerp(bottomColor, topColor, (output[i].position.y - bottomY) / uiElementHeight);
                }
                else
                {
                    Color32 c = Color32.Lerp(bottomColor, topColor, (output[i].position.y - bottomY) / uiElementHeight);
                    if (m_UseRGB)
                    {
                        c.r = (byte)((int)c.r + (int)v.color.r - 255);
                        c.g = (byte)((int)c.g + (int)v.color.g - 255);
                        c.b = (byte)((int)c.b + (int)v.color.b - 255);
                    }
                    if (m_UseGraphicAlpha)
                    {
                        c.a = (byte)((c.a * v.color.a) / 255);
                    }
                    v.color = c;
                }

                output[i] = v;
            }
        }


        vh.Clear();
        vh.AddUIVertexTriangleStream(output);
        output.Clear();
        TypePool <List <UIVertex> > .Put(output);
    }