Skip to content

Commit

Permalink
Merge pull request #7 from Joshuarox100/development
Browse files Browse the repository at this point in the history
v1.0.5 Merge
  • Loading branch information
Joshuarox100 authored Dec 27, 2020
2 parents 3e00ef8 + 7a13c40 commit c582aae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
26 changes: 23 additions & 3 deletions Editor/Scripts/InventoryInventor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void CreateInventory()
{
break;
}
switch (param.name)
switch (param.name)
{
case "Inventory":
if (param.valueType == VRCExpressionParameters.ValueType.Int)
Expand Down Expand Up @@ -189,7 +189,7 @@ Get FX Animator.
bool humanoid = avatar.baseAnimationLayers.Length == 5;

AnimatorController animator = controller != null ? controller : null;

// Replace the Animator Controller in the descriptor if this Controller was there to begin with.
bool replaceAnimator = humanoid ? (animator != null && avatar.baseAnimationLayers[4].animatorController != null && animator == (AnimatorController)avatar.baseAnimationLayers[4].animatorController) : (animator != null && avatar.baseAnimationLayers[2].animatorController != null && animator == (AnimatorController)avatar.baseAnimationLayers[2].animatorController);

Expand Down Expand Up @@ -252,7 +252,7 @@ Get FX Animator.

EditorUtility.DisplayProgressBar("Inventory Inventor", string.Format("Removing Layers: {0}", animator.layers[i].name), 0.05f * (((animator.layers.Length - i) + 1f) / animator.layers.Length));
}
}
}
newAnimator.SaveController();

// Replace the old Animator Controller.
Expand Down Expand Up @@ -283,6 +283,7 @@ Create parameters.

// Check if the parameters already exist. If one does as the correct type, use it. If one already exists as the wrong type, abort.
bool[] existing = new bool[totalToggles + 2];

for (int i = 0; i < srcParam.Length; i++)
{
EditorUtility.DisplayProgressBar("Inventory Inventor", "Creating Parameters", 0.05f + (0.025f * (float.Parse(i.ToString()) / srcParam.Length)));
Expand Down Expand Up @@ -358,6 +359,7 @@ Create parameters.
{
newAnimator.AddParameter("Inventory " + (i + 1), AnimatorControllerParameterType.Bool);
}

}
else if (i == existing.Length - 2)
{
Expand Down Expand Up @@ -385,6 +387,24 @@ Create layers.
CreateMasterLayer(newAnimator, totalToggles, out List<PageItem> items, out List<KeyValuePair<List<int>, List<int>>> activeStates);
CreateItemLayers(newAnimator, ref items, ref activeStates);

/*
Set default bool states.
*/

srcParam = newAnimator.parameters;
for (int i = 0; i < items.Count; i++)
{
for (int j = 0; j < srcParam.Length; j++)
{
if (srcParam[i].name == "Inventory " + (i + 1))
{
srcParam[i].defaultBool = items[i].InitialState;
break;
}
}
}
newAnimator.parameters = srcParam;

EditorUtility.DisplayProgressBar("Inventory Inventor", "Saving Controller", 0.9f);
newAnimator.SaveController();
AssetDatabase.SaveAssets();
Expand Down
2 changes: 1 addition & 1 deletion Editor/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.4
v1.0.5

0 comments on commit c582aae

Please sign in to comment.