1. Setting Material

2. Input Meterial to MeshRenderer

3. Setting TestEmission Component

4. Play And Show


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 |
댓글
댓글 쓰기