您的位置:首页 > 移动开发 > Unity3D

unity meshrender理解

2016-08-07 11:38 405 查看

网格渲染器,其中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;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: