-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsub_HandColorChange.cs
225 lines (175 loc) · 8.18 KB
/
sub_HandColorChange.cs
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class sub_HandColorChange : MonoBehaviour
{
public float limit; //色が変わりきる時間
float countT = 0; //経過時間
private Material BaseMaterial;
private Color ChangeColor;
private Color BufColor;
private float R = 0;
private float G = 0;
private float B = 0;
public GameObject hand;
private bool col;//衝突判定
public int ColorNumber = 0;//変わる色の切り替え
public int ColorNumberCount = 0;
// Start is called before the first frame update
void Start()
{
BaseMaterial = this.GetComponent<Renderer>().material;//手のマテリアル
ChangeColor = BaseMaterial.color; //変色用変数
BufColor = BaseMaterial.color; //原色を保持する変数
Debug.Log(BaseMaterial.color.r);
}
// Update is called once per frame
void Update()
{
col = hand.GetComponent<handcollider>().c;
countT += Time.deltaTime;
float deltaT = Time.deltaTime;
if (Input.GetKeyDown(KeyCode.C))
{
ColorNumberCount += 1;
if (ColorNumberCount == 8)
{
ColorNumberCount = 0;
}
ColorNumber = ColorNumberCount;
}
if (col)//衝突したら
{
switch (ColorNumber)
{
case 0://変化なし
break;
case 1://赤
//させたい色のRGB値
R = 255;
G = 0;
B = 0;
ChangeColor.r += ((R - BaseMaterial.color.r * 255) * deltaT / (limit * 255));
ChangeColor.g += ((G - BaseMaterial.color.g * 255) * deltaT / (limit * 255));
ChangeColor.b += ((B - BaseMaterial.color.b * 255) * deltaT / (limit * 255));
this.GetComponent<Renderer>().material.color = new Color(ChangeColor.r, ChangeColor.g, ChangeColor.b);
if (Input.GetKeyDown(KeyCode.R))
{
Debug.Log("time" + countT);
Debug.Log("RED" + ChangeColor.r);
Debug.Log("GREEN" + ChangeColor.g);
Debug.Log("BLUE" + ChangeColor.b);
}
break;
case 2://オレンジ
//させたい色のRGB値
R = 255;
G = 127;
B = 0;
ChangeColor.r += ((R - BaseMaterial.color.r * 255) * deltaT / (limit * 255));
ChangeColor.g += ((G - BaseMaterial.color.g * 255) * deltaT / (limit * 255));
ChangeColor.b += ((B - BaseMaterial.color.b * 255) * deltaT / (limit * 255));
this.GetComponent<Renderer>().material.color = new Color(ChangeColor.r, ChangeColor.g, ChangeColor.b);
if (Input.GetKeyDown(KeyCode.R))
{
Debug.Log("time" + countT);
Debug.Log("RED" + ChangeColor.r);
Debug.Log("GREEN" + ChangeColor.g);
Debug.Log("BLUE" + ChangeColor.b);
}
break;
case 3://黄
//させたい色のRGB値
R = 255;
G = 255;
B = 0;
ChangeColor.r += ((R - BaseMaterial.color.r * 255) * deltaT / (limit * 255));
ChangeColor.g += ((G - BaseMaterial.color.g * 255) * deltaT / (limit * 255));
ChangeColor.b += ((B - BaseMaterial.color.b * 255) * deltaT / (limit * 255));
this.GetComponent<Renderer>().material.color = new Color(ChangeColor.r, ChangeColor.g, ChangeColor.b);
if (Input.GetKeyDown(KeyCode.R))
{
Debug.Log("time" + countT);
Debug.Log("RED" + ChangeColor.r);
Debug.Log("GREEN" + ChangeColor.g);
Debug.Log("BLUE" + ChangeColor.b);
}
break;
case 4://赤とマゼンタの 中間
//させたい色のRGB値
R = 255;
G = 0;
B = 127;
ChangeColor.r += ((R - BaseMaterial.color.r * 255) * deltaT / (limit * 255));
ChangeColor.g += ((G - BaseMaterial.color.g * 255) * deltaT / (limit * 255));
ChangeColor.b += ((B - BaseMaterial.color.b * 255) * deltaT / (limit * 255));
this.GetComponent<Renderer>().material.color = new Color(ChangeColor.r, ChangeColor.g, ChangeColor.b);
if (Input.GetKeyDown(KeyCode.R))
{
Debug.Log("time" + countT);
Debug.Log("RED" + ChangeColor.r);
Debug.Log("GREEN" + ChangeColor.g);
Debug.Log("BLUE" + ChangeColor.b);
}
break;
case 5://シアン
//させたい色のRGB値
R = 0;
G = 255;
B = 255;
ChangeColor.r += ((R - BaseMaterial.color.r * 255) * deltaT / (limit * 255));
ChangeColor.g += ((G - BaseMaterial.color.g * 255) * deltaT / (limit * 255));
ChangeColor.b += ((B - BaseMaterial.color.b * 255) * deltaT / (limit * 255));
this.GetComponent<Renderer>().material.color = new Color(ChangeColor.r, ChangeColor.g, ChangeColor.b);
if (Input.GetKeyDown(KeyCode.R))
{
Debug.Log("time" + countT);
Debug.Log("RED" + ChangeColor.r);
Debug.Log("GREEN" + ChangeColor.g);
Debug.Log("BLUE" + ChangeColor.b);
}
break;
case 6://青とシアンの間
//させたい色のRGB値
R = 0;
G = 127;
B = 255;
ChangeColor.r += ((R - BaseMaterial.color.r * 255) * deltaT / (limit * 255));
ChangeColor.g += ((G - BaseMaterial.color.g * 255) * deltaT / (limit * 255));
ChangeColor.b += ((B - BaseMaterial.color.b * 255) * deltaT / (limit * 255));
this.GetComponent<Renderer>().material.color = new Color(ChangeColor.r, ChangeColor.g, ChangeColor.b);
if (Input.GetKeyDown(KeyCode.R))
{
Debug.Log("time" + countT);
Debug.Log("RED" + ChangeColor.r);
Debug.Log("GREEN" + ChangeColor.g);
Debug.Log("BLUE" + ChangeColor.b);
}
break;
case 7://青
//させたい色のRGB値
R = 0;
G = 0;
B = 255;
ChangeColor.r += ((R - BaseMaterial.color.r * 255) * deltaT / (limit * 255));
ChangeColor.g += ((G - BaseMaterial.color.g * 255) * deltaT / (limit * 255));
ChangeColor.b += ((B - BaseMaterial.color.b * 255) * deltaT / (limit * 255));
this.GetComponent<Renderer>().material.color = new Color(ChangeColor.r, ChangeColor.g, ChangeColor.b);
if (Input.GetKeyDown(KeyCode.R))
{
Debug.Log("time" + countT);
Debug.Log("RED" + ChangeColor.r);
Debug.Log("GREEN" + ChangeColor.g);
Debug.Log("BLUE" + ChangeColor.b);
}
break;
}
}
else
{
ChangeColor = new Color(BufColor.r, BufColor.g, BufColor.b);
this.GetComponent<Renderer>().material.color = new Color(BufColor.r, BufColor.g, BufColor.b);
countT = 0;
}
}
}