当前位置:网站首页>不同物体使用同一材质,有不同的表现
不同物体使用同一材质,有不同的表现
2022-06-23 22:15:00 【心前阳光】
知识点
材质属性块 MaterialPropertyBlock
设置材质块颜色属性 MaterialPropertyBlock.SetColor
复制一份材质的属性块 Renderer.GetPropertyBlock
设置材质属性块 Renderer.SetPropertyBlock
实现
- 通过模型的Render获取材质块;
- 设置材质块的颜色属性;
- 设置Render的材质块。
using UnityEngine;
public class NotSameDisplay : MonoBehaviour
{
Renderer render;
void Start()
{
render = GetComponent<Renderer>();
ChangeMaterilaColor();
}
void ChangeMaterilaColor()
{
MaterialPropertyBlock newBlock = new MaterialPropertyBlock();
//render的材质数值复制到newBlock中
render.GetPropertyBlock(newBlock);
//参数一:shader中对应的属性名
//选择材质 点击右上角的齿轮 选择Edit Shader 在Properties块中可以查看
//参数二:属性对应的值
newBlock.SetColor("_Color",Color.red);
//将新值复制到属性中
render.SetPropertyBlock(newBlock);
}
}
边栏推荐
- laravel之任务队列
- Big guy on security privacy computing escort data security needs to pay attention to science and technology ethics at the same time
- C # read the occupied size of memory module and hard disk
- 高仿书旗小说 Flutter 版,学起来
- Some explanations of Tim timer of embedded interface and STM32 template library function of NVIC
- Go language core 36 lectures (go language practice and application 23) -- learning notes
- 6. STM32 - serial port data transceiver Foundation
- iNFTnews | 创造者经济的未来在Web3世界中该去向何处?
- "Shanda Diwei Cup" the 12th Shandong ICPC undergraduate program design competition
- 网站如何在Google建立索引
猜你喜欢

三款很酷很骚气的底部导航

How can wechat video numbers be broadcast live on a PC?

2022山东健博会,济南国际大健康产业博览会,中国营养健康展

Golang 类型断言

Is the geTx status management in the flutter really so good to use?

NLog details

MySQL索引底层为什么用B+树?看完这篇文章,轻松应对面试。

Stm32 - - - - interruption externe

What is the production process of enterprise website? How long does it take to design and build a website?

Stm32-------adc (voltage detection)
随机推荐
一个人竟然撸了一个微博 APP
Kotlin 集合List 、Set、Map操作汇总
Avoid confusion when switching between arouter components
How can wechat video numbers be broadcast live on a PC?
2022山东健博会,济南国际大健康产业博览会,中国营养健康展
图论(最近公共祖先LCA)
Postman return value Chinese garbled????
微信视频号如何用 PC 电脑做直播?
2022年信息安全工程师考试知识点:访问控制
"Shanda Diwei Cup" the 12th Shandong ICPC undergraduate program design competition
【HackTheBox】 meow
Common core resource objects of kubernetes
Math. Max() method obtains the maximum value in the array and returns Nan problem analysis
7、STM32——LCD
2022 point de connaissance de l'examen des ingénieurs en sécurité de l'information: contrôle d'accès
Stm32 - - - - interruption externe
BroadcastReciver 和LocalBroadcastManager区别
Which securities dealers recommend? Is online account opening safe?
STM32-------外部中断
嵌入式接口复习资料