-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangeMeshColorWithPicker.cs
More file actions
103 lines (93 loc) · 3.06 KB
/
ChangeMeshColorWithPicker.cs
File metadata and controls
103 lines (93 loc) · 3.06 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
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
using VTS.Networking.Impl;
using VTS.Models.Impl;
using VTS.Models;
using VTS;
using UnityEngine;
using UnityEngine.UI;
using HSVPicker;
using System.Text.RegularExpressions;
using UnityEditor;
public class ChangeMeshColorWithPicker : VTSPlugin
{
[SerializeField]
public Button eyeCheckbtn;
public ColorPicker pickerR;
public ColorPicker pickerL;
public Toggle syncColor;
public Text infoText;
private Color32 MeshColor = new Color32();
private ArtMeshMatcher AmmR = new ArtMeshMatcher();
private ArtMeshMatcher AmmL = new ArtMeshMatcher();
private string[] nameArrayEyeR = { "EyeballR" };
private string[] nameArrayEyeL = { "EyeballL" };
private string[] nameArrayEyes = { "EyeballR", "EyeballL" };
// Start is called before the first frame update
void Start()
{
// Everything you need to get started!
Initialize(
new WebSocketImpl(),
new JsonUtilityImpl(),
new TokenStorageImpl(),
() => { Debug.Log("Connected!"); },
() => { Debug.LogWarning("Disconnected!"); },
() => { Debug.LogError("Error!"); });
AmmR.tintAll = false;
AmmL.tintAll = false;
AmmR.nameContains = nameArrayEyeR;
AmmL.nameContains = nameArrayEyeL;
// Listener
eyeCheckbtn.onClick.AddListener(() => eyeCheck());
syncColor.onValueChanged.AddListener(setMeshList);
pickerR.onValueChanged.AddListener(color =>
{
MeshColor = color;
this.TintArtMesh(MeshColor, 1, AmmR, (onSuccess) => { }, (onError) => { });
});
pickerL.onValueChanged.AddListener(color =>
{
MeshColor = color;
this.TintArtMesh(MeshColor, 1, AmmL, (onSuccess) => { }, (onError) => { });
});
}
void eyeCheck()
{
this.GetArtMeshList(
(onSuccess) =>
{
int i = 0;
string text = "";
while (i < onSuccess.data.artMeshNames.Length)
{
if (Regex.IsMatch(onSuccess.data.artMeshNames[i], "^.*Eyeball.*$"))
{
text = "Eyeball is founded.";
break;
}
i++;
}
if(i >= onSuccess.data.artMeshNames.Length) {
text = "Eyeball is not founded.";
}
infoText.text = text;
},
(onError) => {
infoText.text = "An error occurred.";
});
}
void setMeshList(bool isOn)
{
if (isOn)
{
AmmR.nameContains = nameArrayEyes;
AmmL.nameContains = nameArrayEyes;
pickerL.gameObject.SetActive(false);
}
else
{
AmmR.nameContains = nameArrayEyeR;
AmmL.nameContains = nameArrayEyeL;
pickerL.gameObject.SetActive(true);
}
}
}