简体   繁体   English

如何在Unity中更改游戏object材质?

[英]How to change game object Material in Unity?

How can I do if cube1 collision cube2, cube1 material = yesil? cube1碰撞cube2,cube1材质=yesil怎么办? I'm new in Unity and English speaking sorry about that:)我是 Unity 的新手,对此我说英语很抱歉:)

You are changing the material of the Mesh Renderer component of the game object. Hence, get a reference to the Mesh Renderer and change its material.您正在更改游戏 object 的网格渲染器组件的材质。因此,获取对网格渲染器的引用并更改其材质。

red.GetComponent<MeshRenderer>().material = yesil;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM