using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Setmesh : MonoBehaviour
{
/// <summary>
/// 从面板获取物体的组件MeshRenderer
/// </summary>
public MeshRenderer mesh;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
/// <summary>
/// 切换材质的函数
/// </summary>
/// <param name="mat">材质参数,从面板赋予</param>
public void MeshRender(Material mat)//通过添加事件直接调用
{
mesh.material = mat;
}
}
文章来源:https://www.toymoban.com/news/detail-521787.html
文章来源地址https://www.toymoban.com/news/detail-521787.html
到了这里,关于Unity通过脚本更改物体的材质的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!