当前位置:网站首页>材质 动态自发光
材质 动态自发光
2022-06-29 14:45:00 【心前阳光】
动态修改材质自发光
- 新建一个场景,关闭方向光;目的:自发光更明显
- 创建2个立方体;
- 创建一个材质;
- 材质赋值给新建的两个立方体;
- 两个立方体挂载脚本。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestEmssion : MonoBehaviour
{
MaterialPropertyBlock block;
Renderer render;
private void Start()
{
block = new MaterialPropertyBlock();
render = GetComponent<Renderer>();
}
private void OnMouseEnter()//鼠标移入 碰撞体触发
{
render.GetPropertyBlock(block);
render.material.EnableKeyword("_EMISSION");//开启自发光
block.SetColor("_EmissionColor", Color.blue);//设置颜色
render.SetPropertyBlock(block);
}
private void OnMouseExit()//鼠标移出 碰撞体触发
{
render.GetPropertyBlock(block);
block.SetColor("_EmissionColor", Color.blue);//设置颜色
render.material.DisableKeyword("_EMISSION");//关闭高光
render.SetPropertyBlock(block);
}
}
存在问题
编辑模式下,有高光效果。发布后,没有高光效果。
解决方法
- 材质勾选Emssion;
- Global Illumination 设置为Realtime或者None即可
原因
Global Illumination:指定此材质发出的光如何影响附近其他游戏对象的环境光照。
- Realtime:Unity 将此材质的⾃发光添加到场景的 Realtime Global Illumination(实时全局光照)计算中。这意味着此⾃发光会影响附近游戏对象(包括正在移动的游戏对象)的光照。
- Baked:Unity 将此材质的⾃发光烘焙到场景的静态全局光照中。此材质会影响附近静态游戏对象的光照,但不会影响动态游戏对象的光照。但是,光照探针仍然会影响动态游戏对象的光照。
- None:此材质的⾃发光不会影响场景中的实时光照贴图、烘焙光照贴图或光照探针。此⾃发光不会照亮或影响其他游戏对象。
边栏推荐
- 墨滴排版
- Ogg synchronize MySQL data to greenplus
- Uniapp problem list and experience
- 高並發軟件(網站,服務器端接口)的評價指標
- 【牛客网刷题系列 之 Verilog快速入门】~ 移位运算与乘法
- Chapter 9 of canvas: gradients and shadows
- 驱动器实际运用案例
- Uncover the secret! Pay attention to those machines under the membership system!
- 信息学奥赛一本通1001:Hello,World!
- Chapter 14 of canvas physical animation
猜你喜欢

网易严选离线数仓质量建设实践

驱动器实际运用案例

Intelligent diagnosis of Alzheimer's disease

render后续来了,封装一个表单往表格中添加数据

两个字的名字如何变成有空格的3个字符的名字

Alibaba cloud experience Award: use polardb-x and Flink to build a large real-time data screen

Illustration of Ctrip quarterly report: net revenue of RMB 4.1 billion has been "halved" compared with that before the outbreak

技术沟通遇到3个为什么背后的逻辑

Deploy redis sentry in k8s

Explanation on deployment and establishment of decentraland process
随机推荐
Chapter 13 event operation of canvas
MCS:离散随机变量——Hyper Geometric分布
EMC surge protection and decoupling design
wieshark抓包mysql协议简单分析
PostgreSql学习(基于菜鸟课程)
I want to search the hundreds of nodes in the data warehouse. Can I check a table used in the SQL
高並發軟件(網站,服務器端接口)的評價指標
信息学奥赛一本通1002:输出第二个整数
二级指针
bash汇总线上日志
Chapter 14 of canvas physical animation
卫星运动的微分方程
Intelligent diagnosis of Alzheimer's disease
Using polymorphism to realize simple calculator
Informatics Olympiad all in one 2062: movie tickets
QRcode custom QR code middle picture
知乎热议:一个程序员的水平能差到什么程度?
捷氢科技冲刺科创板:拟募资10.6亿 上汽集团是大股东
我想在数仓的几百个节点里面 查找一个都有哪些sql里面用到了某张表 能查吗
ROS 笔记(10)— launch 文件启动