-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalphaChange.cs
More file actions
47 lines (37 loc) · 1.23 KB
/
alphaChange.cs
File metadata and controls
47 lines (37 loc) · 1.23 KB
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
47
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class alphaChange : MonoBehaviour
{
// Start is called before the first frame update
public float alphaLevel = 1.0f;
public KeyCode decreaseAlpha;
public KeyCode increaseAlpha;
GameObject[] respawns;
void Start()
{
}
// Update is called once per frame
void Update()
{
respawns =GameObject.FindGameObjectsWithTag("cell");
if (Input.GetKeyDown(increaseAlpha)) //Debug.Log("im a " + transform.parent.gameObject.name);
{
alphaLevel += 0.1f;
foreach (GameObject go in respawns)
{
Color c = go.GetComponent<MeshRenderer>().material.color;
go.GetComponent<MeshRenderer>().material.color = new Color(c.r, c.g, c.b, alphaLevel);
}
}
if (Input.GetKeyDown(decreaseAlpha))
{
alphaLevel -= 0.1f;
foreach (GameObject go in respawns)
{
Color c = go.GetComponent<MeshRenderer>().material.color;
go.GetComponent<MeshRenderer>().material.color = new Color(c.r, c.g, c.b, alphaLevel);
}
}
}
}