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>
/// 切換材質的函數(shù)
/// </summary>
/// <param name="mat">材質參數(shù),從面板賦予</param>
public void MeshRender(Material mat)//通過添加事件直接調用
{
mesh.material = mat;
}
}
?文章來源:http://www.zghlxwxcb.cn/news/detail-521787.html
?文章來源地址http://www.zghlxwxcb.cn/news/detail-521787.html
到了這里,關于Unity通過腳本更改物體的材質的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!