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
|
#if VRC_SDK_VRCSDK3
using UnityEngine;
using UnityEditor;
using VRC.SDK3.Avatars.Components;
using VRC.SDK3.Editor;
using VRC.SDKBase.Editor;
[CustomEditor(typeof(VRCAvatarDescriptor))]
public partial class AvatarDescriptorEditor3 : Editor
{
VRCAvatarDescriptor avatarDescriptor;
VRC.Core.PipelineManager pipelineManager;
static bool _repaint = false;
public void OnEnable()
{
/*
if (EyelidSkinnedMesh == null)
EyelidSkinnedMesh = (target as Component).GetComponentInChildren<SkinnedMeshRenderer>(true);
if (EyelidBlendShapes == null)
EyelidBlendShapes = GetBlendShapeNames(EyelidSkinnedMesh);
*/
if (avatarDescriptor == null)
avatarDescriptor = (VRCAvatarDescriptor)target;
if (pipelineManager == null)
{
pipelineManager = avatarDescriptor.GetComponent<VRC.Core.PipelineManager>();
if (pipelineManager == null)
avatarDescriptor.gameObject.AddComponent<VRC.Core.PipelineManager>();
}
if (!_doCustomizeAnimLayers.boolValue)
ResetAnimLayersToDefault();
EnforceAnimLayerSetup(true);
serializedObject.ApplyModifiedProperties();
InitEyeLook();
Init_Expressions();
}
public void OnSceneGUI()
{
serializedObject.Update();
//Draw
DrawSceneViewpoint();
DrawSceneEyeLook();
DrawSceneLipSync();
serializedObject.ApplyModifiedProperties();
}
public override void OnInspectorGUI()
{
serializedObject.Update();
if(VRCSdkControlPanel.window != null)
{
if( GUILayout.Button( "Select this avatar in the SDK control panel" ) )
VRCSdkControlPanelAvatarBuilder.SelectAvatar(avatarDescriptor);
}
DrawView();
DrawLipSync();
DrawEyeLook();
DrawPlayableLayers();
DrawLowerBodySettings();
DrawInspector_Expressions();
DrawFooter();
serializedObject.ApplyModifiedProperties();
if (_repaint)
EditorUtility.SetDirty(target);
}
void DrawFooter()
{
if (!string.IsNullOrEmpty(avatarDescriptor.unityVersion))
EditorGUILayout.LabelField("Unity Version: ", avatarDescriptor.unityVersion);
if (_animator)
EditorGUILayout.LabelField("Rig Type: ", (_animator.isHuman ? "Humanoid" : "Non-humanoid"));
GUILayout.Space(5);
}
#region GUIHelperMethods
static bool Foldout(string editorPrefsKey, string label, bool deft = false)
{
bool prevState = EditorPrefs.GetBool(editorPrefsKey, deft);
bool state = EditorGUILayout.Foldout(prevState, label);
if (state != prevState)
EditorPrefs.SetBool(editorPrefsKey, state);
return state;
}
public static void Separator()
{
GUILayout.Space(5);
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(2));
r.height = 2;
r.x -= 10;
r.width += 20;
EditorGUI.DrawRect(r, new Color(0, 0, 0, 0.15f));
GUILayout.Space(5);
}
void MinMaxSlider(string label, SerializedProperty minFloat, SerializedProperty maxFloat, float minLimit, float maxLimit, bool rounded = true)
{
float min = minFloat.floatValue;
float max = maxFloat.floatValue;
EditorGUI.BeginChangeCheck();
MinMaxSlider(label, ref min, ref max, minLimit, maxLimit, rounded);
if (EditorGUI.EndChangeCheck())
{
minFloat.floatValue = min;
maxFloat.floatValue = max;
}
}
void MinMaxSlider(string label, ref float minValue, ref float maxValue, float minLimit, float maxLimit, bool rounded = true)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(label);
minValue = Mathf.Clamp(System.Convert.ToSingle(EditorGUILayout.TextField(minValue.ToString(), GUILayout.MaxWidth(30))), minLimit, maxValue);
EditorGUILayout.MinMaxSlider(
ref minValue,
ref maxValue, minLimit, maxLimit);
maxValue = Mathf.Clamp(System.Convert.ToSingle(EditorGUILayout.TextField(maxValue.ToString(), GUILayout.MaxWidth(30))), minValue, maxLimit);
if (rounded)
{
minValue = Mathf.Round(minValue);
maxValue = Mathf.Round(maxValue);
}
EditorGUILayout.EndHorizontal();
}
static GUIStyle boxStyle;
static void BeginBox(string label, bool hasFoldouts = false)
{
Rect rect = EditorGUILayout.BeginVertical();
GUILayout.Space(ANIM_LAYER_LIST_MARGIN * 2);
EditorGUILayout.BeginHorizontal(GUI.skin.box);
GUILayout.Space(ANIM_LAYER_LIST_MARGIN + (hasFoldouts ? 8:0));
EditorGUILayout.BeginVertical();
if (!string.IsNullOrEmpty(label))
{
GUILayout.BeginHorizontal();
GUILayout.Space(-(hasFoldouts ? 8 : 0));
GUILayout.Label(label, EditorStyles.boldLabel);
GUILayout.EndHorizontal();
}
}
static void EndBox()
{
EditorGUILayout.EndVertical();
GUILayout.Space(ANIM_LAYER_LIST_MARGIN);
EditorGUILayout.EndHorizontal();
EditorGUILayout.EndVertical();
// encompassing boxes must be drawn last
/*Rect rect2 = GUILayoutUtility.GetLastRect();
rect2.y -= ANIM_LAYER_LIST_MARGIN;
rect2.height += (ANIM_LAYER_LIST_MARGIN * 2.35f);
GUI.color = boxColor;
for (int v = 0; v < (boxColor == Color.black ? 3 : 1); v++)
{
GUI.Box(rect2, GUIContent.none);
}
GUI.color = Color.white;
EditorGUILayout.EndVertical();
GUILayout.Space(ANIM_LAYER_LIST_MARGIN * 2);*/
}
#endregion
}
#endif
|