简述unity中material.color及Color.Lerp线性插值的用法
来源:互联网 发布:电脑怎么识别不了网络 编辑:程序博客网 时间:2024/06/01 10:29
代码:
using UnityEngine;using System.Collections;public class Colorr : MonoBehaviour { public Color colorStart = Color.red; public Color colorEnd = Color.blue; public float time = 1f; public Renderer ren;void Start () { ren = GetComponent<Renderer>();}// Update is called once per framevoid Update () { float lerp = Mathf.PingPong(Time.time, time) / time; ren.material.color = Color.Lerp(colorStart, colorEnd, lerp);}}
Render组件和transform,rigidbody一样需获得其组件,然后再调用相关方法,修改Render的相关属性,Renderer下有一个成员变量material是返回分配给材质器的
第一个材质,注意和materials区别(返回所有材质)。material.color是获得颜色。
Color.Lerp(colorStart,colorEnd,lerp) 是在开始颜色和结束颜色中线性选择颜色赋值给material.color,lerp是循环的时间(后述)。
代码效果:将脚本赋予一个cube,则看到cube不停变换颜色,在red到blue之间。
1 0
- 简述unity中material.color及Color.Lerp线性插值的用法
- Color.Lerp 线性插值
- 简述unity中给一堆cube赋予各种颜色值material.color,随机方法Random.Range的使用
- android中color的用法及十六进制编码大全
- unity Mathf Lerp 的用法
- unity中Lerp的使用
- Unity之Vector3.Lerp线性插值原理介绍
- golang中image/color包的用法
- ECharts中color : function的用法
- Android 5.1 Material Design 中Color 设置
- Material Desing Color
- android color Material Design
- unity中mathf.Lerp的运用
- android中?attr/**与@drawable/**或@color/**等的区别及用法
- Unity 的 mathf.lerp
- android中使用material design的问题-Cannot resolve symbol: @color:material_blue_500
- 简述unity中Destory的用法
- Material design 之 Style中Color配色方案
- Python3爬虫从入门到自残(二):HTML及其解析
- Spark配置参数
- 27. Remove Element
- PAT 乙级 1042. 字符统计(20) Java版
- iOS检测设备摄像头、指南针、录音、陀螺仪状态
- 简述unity中material.color及Color.Lerp线性插值的用法
- HDU
- 39. Combination Sum
- 内存对齐宏ALIGN
- java取整和java四舍五入方法
- 隐马尔可夫模型(四)——隐马尔可夫模型的评估问题(后向算法)
- 349. Intersection of Two Arrays & 350. Intersection of Two Arrays II
- HTML、CSS学习笔记
- 一天浓缩学习webpack经过