字体加粗特效

这个是让字体变粗,这个功能是转载别人的,但是忘记链接了,是别人写的。

/*--------------------------------------------------------------------

  • Author Name: DXL
  • Creation Time: 7/4/2019 4:57:36 PM
  • File Describe: 字体加粗效果
  • ------------------------------------------------------------------*/

using UnityEngine;
using System.Collections.Generic;
using UnityEngine.UI;
[RequireComponent(typeof(Text))]
public class BoldTextEffect : BaseMeshEffect
{
[Range(0, 1)] public float Alpha;
[Range(1, 5)] public int Strength;

private Text m_Text = null;

private Text TextComp
{
    get
    {
        if (m_Text == null)
        {
            m_Text = GetComponent<Text>();
        }

        return m_Text;
    }
}

private Color effectColor
{
    get
    {
        if (TextComp == null)
        {
            return Color.black;
        }

        return TextComp.color;
    }
}


protected void ApplyShadowZeroAlloc(List<UIVertex> verts, Color32 color, int start, int end, float x, float y)
{
    int num = verts.Count + end - start;
    if (verts.Capacity < num)
        verts.Capacity = num;
    for (int index = start; index < end; ++index)
    {
        UIVertex vert = verts[index];
        verts.Add(vert);
        Vector3 position = vert.position;
        position.x += x;
        position.y += y;
        vert.position = position;
        Color32 color32 = color;
        color32.a = (byte)((int)color32.a * (int)verts[index].color.a / (int)byte.MaxValue);
        color32.a = (byte)(Alpha * color32.a);
        vert.color = color32;
        verts[index] = vert;
    }
}

public override void ModifyMesh(VertexHelper vh)
{
    if (!IsActive())
    {
        return;
    }

    List<UIVertex> verts = new List<UIVertex>();
    vh.GetUIVertexStream(verts);


    for (int i = 0; i < Strength; ++i)
    {
        ApplyShadowZeroAlloc(verts, effectColor, 0, verts.Count, 0, 0);
    }

    vh.Clear();
    vh.AddUIVertexTriangleStream(verts);
}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值