using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mpingpong : MonoBehaviour
{
Material material1;
Material material2;
public float dunation = 1.0f;
void Start()
{
material1 = Resources.Load("A") as Material;//材质球
material2 = Resources.Load("B") as Material;//材质球
GetComponent<Renderer>().material = material1;
}
void Update()
{
float lerp = Mathf.PingPong(Time.time, dunation)/dunation;
GetComponent<Renderer>().material.Lerp(material1, material2, lerp);
}
}
颜色闪烁
最新推荐文章于 2023-10-26 22:42:07 发布
此篇博客介绍了一个使用Unity3D开发的游戏场景,Mpingpong脚本通过PingPong函数实现乒乓球的材质实时平滑切换,利用Lerp方法控制两个预加载的材质球。适合学习Unity材质管理和动画效果。
785

被折叠的 条评论
为什么被折叠?



