Skip to content

Commit

Permalink
fixed bug in which parameter slot was not being created.
Browse files Browse the repository at this point in the history
changed wording of error message.
  • Loading branch information
chibiskuld committed Aug 28, 2021
1 parent 1cdeaef commit c3a0f34
Showing 1 changed file with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public enum VRCGesture { Neutral, Fist, HandOpen, FingerPoint, Victory, RockNRol
private Hand hand = Hand.Right;
private VRCGesture activateGesture = VRCGesture.FingerPoint;
private VRCGesture resetGesture = VRCGesture.HandOpen;
GUIStyle versionStyle;

public void OnEnable()
{
Expand All @@ -48,6 +49,9 @@ public void OnEnable()

if (!findAvatarAndAnimationPath(obj.transform)) return;
findComponents();
versionStyle = GUIStyle.none;
versionStyle.padding = new RectOffset(10, 10, 10, 10);
versionStyle.alignment = TextAnchor.MiddleCenter;
}
public override void OnInspectorGUI()
{
Expand Down Expand Up @@ -76,6 +80,19 @@ public override void OnInspectorGUI()
GUILayout.Label("Select a location for the marker:");
ShowMenuFoldout(avatarDescriptor.expressionsMenu, "Expressions Menu");
}


GUILayout.TextArea("Snail Marker Generator Version 3.1.2 (c) 2021 Snail & Skuld", versionStyle);
}

private int GetParameterSize()
{
int size = 0;
for (int i = 0; i < expressionParams.parameters.Length; i++)
{
size += VRCExpressionParameters.TypeCost(expressionParams.parameters[i].valueType);
}
return size;
}

private HashSet<VRCExpressionsMenu> expandedMenus = new HashSet<VRCExpressionsMenu>();
Expand All @@ -97,11 +114,7 @@ private void ShowMenuFoldout(VRCExpressionsMenu menu, string title)
GUILayout.BeginHorizontal();
GUILayout.Space(EditorGUI.indentLevel * 17);

int size = 0;
for (int i = 0; i < expressionParams.parameters.Length; i++)
{
size += VRCExpressionParameters.TypeCost(expressionParams.parameters[i].valueType);
}
int size = GetParameterSize();

if ( menu.controls.Count < expressionParams.parameters.Length )
{
Expand Down Expand Up @@ -176,7 +189,23 @@ private void AddParameter()
return;
}
}
Debug.LogError("Could not create Avatar 3.0 parameter. You may be out of paramters.");
int size = GetParameterSize();
if ( size < 128)
{
int n = expressionParams.parameters.Length;
VRCExpressionParameters.Parameter[] newParams = new VRCExpressionParameters.Parameter[n + 1];
for ( int i = 0; i < n; i++)
{
newParams[i] = expressionParams.parameters[i];
}
newParams[n] = new VRCExpressionParameters.Parameter();
newParams[n].name = "ToggleMarker";
newParams[n].valueType = VRCExpressionParameters.ValueType.Bool;
expressionParams.parameters = newParams;
EditorUtility.SetDirty(expressionParams);
return;
}
Debug.LogError("Could not create Avatar 3.0 parameter. You may be out of paramters, try creating it manually.");
return;
}
private void AddMarkerToMenu(ref VRCExpressionsMenu menu)
Expand Down Expand Up @@ -425,7 +454,7 @@ private void SetGestureTransitionDefaults(AnimatorStateTransition transition)
}
private void CreateGestureLayer()
{
string layerName = generatedGestureName() + "Maker";
string layerName = generatedGestureName() + "Marker";
AnimatorControllerLayer layer = FindLayer(layerName);
if (layer == null)
{
Expand Down

0 comments on commit c3a0f34

Please sign in to comment.