forked from candycat1992/Unity_Shaders_Book
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBurnHelper.cs
More file actions
34 lines (27 loc) · 705 Bytes
/
Copy pathBurnHelper.cs
File metadata and controls
34 lines (27 loc) · 705 Bytes
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
using UnityEngine;
using System.Collections;
public class BurnHelper : MonoBehaviour {
public Material material;
[Range(0.01f, 1.0f)]
public float burnSpeed = 0.3f;
private float burnAmount = 0.0f;
// Use this for initialization
void Start () {
if (material == null) {
Renderer renderer = gameObject.GetComponentInChildren<Renderer>();
if (renderer != null) {
material = renderer.material;
}
}
if (material == null) {
this.enabled = false;
} else {
material.SetFloat("_BurnAmount", 0.0f);
}
}
// Update is called once per frame
void Update () {
burnAmount = Mathf.Repeat(Time.time * burnSpeed, 1.0f);
material.SetFloat("_BurnAmount", burnAmount);
}
}