Skip to content

Commit

Permalink
[VRChat → VRM] シェイプキーが存在しないアバターで、変換ダイアログを開いたときに例外が発生していたバグを修正
Browse files Browse the repository at this point in the history
Fixes #47
  • Loading branch information
esperecyan committed Jul 23, 2022
1 parent 15ac3e1 commit ba97a22
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions Editor/UI/VRChatToVRMWizard.cs
Expand Up @@ -46,6 +46,7 @@ internal class VRChatToVRMWizard : ScriptableWizard
private VRMMetaObject meta = null;

private IEnumerable<string> shapeKeyNames = null;
private bool noShapeKeys = true;
private string[] maybeBlinkShapeKeyNames = null;
private IEnumerable<AnimationClip> animations = null;
private string[] animationNames = null;
Expand Down Expand Up @@ -170,6 +171,7 @@ protected override bool DrawWizardGUI()
.SelectMany(mesh => SkinnedMeshUtility.GetAllShapeKeys(mesh, useShapeKeyNormalsAndTangents: false))
.Select(shapeKey => shapeKey.Name)
.Distinct();
this.noShapeKeys = this.shapeKeyNames.Count() == 0;

(this.animations, this.expressions)
= VRChatUtility.DetectVRChatExpressions(this.prefabOrInstance, this.shapeKeyNames);
Expand Down Expand Up @@ -226,21 +228,36 @@ protected override bool DrawWizardGUI()
this.isValid = false;
}

EditorGUILayout.LabelField("Expressions", EditorStyles.boldLabel);
foreach (var (preset, field) in VRChatToVRMWizard.PresetFieldPairs)
using (new EditorGUI.DisabledScope(this.noShapeKeys))
{
this.expressionPresetFlagPairs[preset]
= VRChatToVRMWizard.PresetFieldPairs[preset] == nameof(VRChatExpressionBinding.AnimationClip)
? EditorGUILayout.Popup(
EditorGUILayout.LabelField("Expressions", EditorStyles.boldLabel);
foreach (var (preset, field) in VRChatToVRMWizard.PresetFieldPairs)
{
if (this.noShapeKeys)
{
// アバターにシェイプキーが1つも含まれていない場合
EditorGUILayout.Popup(preset.ToString(), 0, new string[] { });
continue;
}

if (VRChatToVRMWizard.PresetFieldPairs[preset] == nameof(VRChatExpressionBinding.AnimationClip))
{
this.expressionPresetFlagPairs[preset] = EditorGUILayout.Popup(
preset.ToString(),
this.expressionPresetFlagPairs[preset],
this.animationNames
)
: EditorGUILayout.MaskField(
);
}
else
{
// まばたき
this.expressionPresetFlagPairs[preset] = EditorGUILayout.MaskField(
preset.ToString(),
this.expressionPresetFlagPairs[preset],
this.maybeBlinkShapeKeyNames
);
}
}
}

EditorGUILayout.LabelField("Other Settings", EditorStyles.boldLabel);
Expand Down

0 comments on commit ba97a22

Please sign in to comment.