-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEnumRandom.cs
More file actions
43 lines (39 loc) · 1.25 KB
/
EnumRandom.cs
File metadata and controls
43 lines (39 loc) · 1.25 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
//GameManager =>
// [Header("Color Settings")]
// public Color32[] itemColors;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeItem : MonoBehaviour
{
public enum CubeColor
{
Color0 = 0,
Color1 = 1,
Color2 = 2,
Color3 = 3
}
[Header("Color Settings")]
public CubeColor m_CubeColorType = CubeColor.Color1;
public MeshRenderer m_meshRenderer;
void Start()
{
m_CubeColorType = (CubeColor)Random.Range(0, Enum.GetValues(typeof(CubeColor)).Length);
Debug.Log(m_CubeColorType);
switch (m_CubeColorType)
{
case CubeColor.Color0:
m_meshRenderer.material.SetColor("_Color", GameManager.instance.itemColors[0]);
break;
case CubeColor.Color1:
m_meshRenderer.material.SetColor("_Color", GameManager.instance.itemColors[1]);
break;
case CubeColor.Color2:
m_meshRenderer.material.SetColor("_Color", GameManager.instance.itemColors[2]);
break;
case CubeColor.Color3:
m_meshRenderer.material.SetColor("_Color", GameManager.instance.itemColors[3]);
break;
}
}
}