unity meshrender理解

时间:2023-03-09 02:59:15
unity meshrender理解

网格渲染器,其中unity里面多有的材质在渲染的时候都是会划分成三角形的,所以当添加一些物体的时候,例如3d text的时候,默认添加网格渲染器。

最常用的就是获取材质。

下面是一个利用网格渲染器获得材质,设置不透明度的例子。

using UnityEngine;
using System.Collections; // Simple class for blinking the visibility of an item on and off [RequireComponent(typeof(Renderer))]
public class BlinkAnim : MonoBehaviour
{
public float blinkTime = 0.6f; void Update()
{
// blink the item on and off using the material alpha.
// use realtimeSinceStartup because Time.time doesn't increase when the game is paused.
bool showTapToStart = Mathf.Repeat(Time.realtimeSinceStartup, 3*blinkTime) > blinkTime;
Color col = GetComponent<Renderer>().material.color;
col.a = showTapToStart ? 1.0f : 0.0f;
GetComponent<Renderer>().material.color = col;
}
}