• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Unity通过脚本更改物体的材质

武飞扬头像
杜星 星
帮助1

  1.  
    using System.Collections;
  2.  
    using System.Collections.Generic;
  3.  
    using UnityEngine;
  4.  
     
  5.  
    public class Setmesh : MonoBehaviour
  6.  
    {
  7.  
    /// <summary>
  8.  
    /// 从面板获取物体的组件MeshRenderer
  9.  
    /// </summary>
  10.  
    public MeshRenderer mesh;
  11.  
    // Start is called before the first frame update
  12.  
    void Start()
  13.  
    {
  14.  
     
  15.  
    }
  16.  
     
  17.  
    // Update is called once per frame
  18.  
    void Update()
  19.  
    {
  20.  
     
  21.  
    }
  22.  
    /// <summary>
  23.  
    /// 切换材质的函数
  24.  
    /// </summary>
  25.  
    /// <param name="mat">材质参数,从面板赋予</param>
  26.  
    public void MeshRender(Material mat)//通过添加事件直接调用
  27.  
    {
  28.  
     
  29.  
    mesh.material = mat;
  30.  
    }
  31.  
    }
学新通

学新通

学新通 

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfkhcbg
系列文章
更多 icon
同类精品
更多 icon
继续加载