纳金网

标题: UGUI字体特效DIY [打印本页]

作者: may    时间: 2015-9-26 00:11
标题: UGUI字体特效DIY

UGUI自带两个字体效果--Outline 和 Shadow

而渐变效果实现木有,以下是一个简单实现:




UGUI文字/UI特效的代码示例
  • using System.Collections.Generic;
  • using UnityEngine;
  • using UnityEngine.UI;
  • /**
  • * Modify the given vertices so they follow a sin curve
  • */
  • public class BaseVertexEffect_Test : BaseVertexEffect
  • {
  •         public float scale = 10f;
  •         public float amplitude = 35f;
  •         public float phase = 0f;
  •         public override void ModifyVertices(List<UIVertex> verts)
  •         {
  •                 if (!IsActive ())
  •                         return;
  •         int prevLength = verts.Count;
  •         for (int index = 0; index < prevLength; index++)
  •                 {
  •                         var uiVertex = verts[index];
  •             uiVertex.color = new Color(0,0,0,0.5f);
  •                         uiVertex.position.z = Mathf.Sin (uiVertex.position.x * scale + phase) * amplitude;
  •             verts.Add(uiVertex);//增加需要渲染的顶点
  •                         //verts[index] = uiVertex;//或者覆盖原来顶点
  •                 }
  •         }
  • }







欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5