1. Setting Material
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWB9Cd5pH9tHlN1N0-5WSFT1uraA3WuZBEapseQvvkZ2ThuPBJW3qJDjKlEcTQ5ir1pebG3cncudW4onZjPmUiITbBx2bjfsLhiRu2FIhvoMty_9cLNajUue425-JgDfsLJiMVFk5HM8I/s640/01.png)
2. Input Meterial to MeshRenderer
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3fS8pWsdJz2f6d_wkQQxWRhEH15dw8SooveZEH8z9OGk7MzVX7wRrKN_O_WcmlGGTy5D5zq2086Eo9BZDDLdD_aab3Hlxfoj78LS4t4CdHPG8wsixkC0_6i_4jiXZY4uelsPHvBlEyGo/s640/02.png)
3. Setting TestEmission Component
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIgUzZTMmq87A2kBPXJ83NLcoY7XzD1J8WqUbf51OotSzknxe0iD2L13ODJ67v8oONmNd4i8tJ1iMf-eVUxI0E-UdguJLztLuXpSh5TCVlVrLbav30o5M9AOPJA7vFdwfZjJFkaBD6_eM/s640/03.png)
4. Play And Show
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0VKThBpN7_8rDHPf9a6IrjUKJ6VHAYmhmDZ84G__v0vCPBhxaRvhaDTwh9BRyA8KBqA4rgQ5BG-_ZcLD_9SGY263I7BCyYfGkR4iDL8n8N14bb8Mv0OQuqoY5fIay5AjkTZTA56ht1ek/s640/04.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhIloZ-E8MWaW9EsUaPw7uZucqV_No2esHOdk3yMIPftTu7lMQwJKgSVC9r-AE44Ep18kVzwWLiWDOJtvGFt_7ziNAg1QJWf3MxzzyB-ZrQ6xVJ67p_ZOqIpAOs2cx-xogjXyUrx4HF1Sc/s640/05.png)
Class TestEmission
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestEmission : MonoBehaviour
{
public Color32 m_color;
public MeshRenderer m_meshRenderer;
public float min = 0f;
public float max = 0.3f;
private void Start()
{
StartCoroutine(EmissionCor());
}
IEnumerator EmissionCor()
{
int swit = 1;
float emission = 0;
while (true)
{
Color baseColor = m_color;
Color finalColor = baseColor * Mathf.LinearToGammaSpace(emission);
m_meshRenderer.material.SetColor("_EmissionColor", finalColor);
emission += (Time.deltaTime * swit * 0.5f);
if (emission > max)
{
swit = -1;
emission = max;
}
else if (emission < min)
{
swit = 1;
emission = min;
yield return new WaitForSeconds(1f);
}
yield return null;
}
}
}
| cs |
댓글
댓글 쓰기