feat: improve usability of manual bake options

* select output avatar on manual bake
* add GameObject context menus
This commit is contained in:
hill 2023-03-23 11:09:41 +01:00 committed by GitHub
parent f584f38303
commit 7d97c75ef8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,6 +66,18 @@ namespace nadena.dev.modular_avatar.core.editor
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
}
[MenuItem("GameObject/[ModularAvatar] Manual bake avatar", true, 49)]
static bool ValidateApplyToCurrentAvatarGameobject()
{
return ValidateApplyToCurrentAvatar();
}
[MenuItem("GameObject/[ModularAvatar] Manual bake avatar", false, 49)]
static void ApplyToCurrentAvatarGameobject()
{
ApplyToCurrentAvatar();
}
[MenuItem("Tools/Modular Avatar/Manual bake avatar", true)]
private static bool ValidateApplyToCurrentAvatar()
{
@ -102,6 +114,7 @@ namespace nadena.dev.modular_avatar.core.editor
BuildReport.Clear();
ProcessAvatar(avatar);
Selection.objects = new Object[] { avatar };
}
finally
{
@ -320,13 +333,13 @@ namespace nadena.dev.modular_avatar.core.editor
var animator = avatarGameObject.GetComponent<Animator>();
var builder = ty_VRCSdkControlPanelAvatarBuilder3A.GetConstructor(Type.EmptyTypes)
.Invoke(Array.Empty<object>());
var perfStats = ty_AvatarPerformanceStats.GetConstructor(new[] {typeof(bool)})
.Invoke(new object[] {false});
var perfStats = ty_AvatarPerformanceStats.GetConstructor(new[] { typeof(bool) })
.Invoke(new object[] { false });
ty_VRCSdkControlPanelAvatarBuilder3A
.GetMethod("RegisterBuilder", BindingFlags.Public | BindingFlags.Instance)
.Invoke(builder, new object[] {tempControlPanel});
.Invoke(builder, new object[] { tempControlPanel });
ty_VRCSdkControlPanelAvatarBuilder3A.GetMethod("ValidateFeatures").Invoke(
builder, new object[] {avatar, animator, perfStats}
builder, new object[] { avatar, animator, perfStats }
);
}
catch (Exception e)
@ -341,4 +354,4 @@ namespace nadena.dev.modular_avatar.core.editor
}
}
}
}
}