Skip to content

Commit

Permalink
feat: use ndmf IsAvatarRoot() for non-VRC AvatarGlobalComponent valid…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
kaikoga committed Oct 23, 2023
1 parent 9d8b737 commit fc9e1df
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Editor/AvatarGlobalComponentEditorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,32 @@

namespace Anatawa12.AvatarOptimizer
{
#if AAO_VRCSDK3_AVATARS
[InitializeOnLoad]
#endif
abstract class AvatarGlobalComponentEditorBase : AvatarTagComponentEditorBase
{
#if AAO_VRCSDK3_AVATARS
static AvatarGlobalComponentEditorBase()
{
ComponentValidation.RegisterValidator<AvatarGlobalComponent>(component =>
{
#if AAO_VRCSDK3_AVATARS
if (!component.GetComponent<VRCAvatarDescriptor>())
return new[] { ErrorLog.Validation("AvatarGlobalComponent:NotOnAvatarDescriptor") };
#else
if (!nadena.dev.ndmf.runtime.RuntimeUtil.IsAvatarRoot(component.transform))
return new[] { ErrorLog.Validation("AvatarGlobalComponent:NotOnAvatarRoot") };
#endif
return null;
});
}
#endif
protected override void OnInspectorGUIInner()
{
#if AAO_VRCSDK3_AVATARS
if (!((Component)serializedObject.targetObject).GetComponent<VRCAvatarDescriptor>())
EditorGUILayout.HelpBox(CL4EE.Tr("AvatarGlobalComponent:NotOnAvatarDescriptor"),
MessageType.Error);
#else
if (!nadena.dev.ndmf.runtime.RuntimeUtil.IsAvatarRoot(((Component)serializedObject.targetObject).transform))
EditorGUILayout.HelpBox(CL4EE.Tr("AvatarGlobalComponent:NotOnAvatarRoot"),
MessageType.Error);
#endif
}
}
Expand Down
3 changes: 3 additions & 0 deletions Localization/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ msgstr "Invert All"
msgid "DeleteEditorOnlyGameObjects:NotOnAvatarDescriptor"
msgstr "This component must be set on root of Avatar (GameObject with AvatarDescriptor)"

msgid "DeleteEditorOnlyGameObjects:NotOnAvatarRoot"
msgstr "This component must be set on root of Avatar (For VRChat avatars, GameObject with AvatarDescriptor)"

# endregion

# region UnusedBonesByReferencesTool
Expand Down
3 changes: 3 additions & 0 deletions Localization/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ msgstr "すべての有効/無効を入れ替える"
msgid "DeleteEditorOnlyGameObjects:NotOnAvatarDescriptor"
msgstr "このコンポーネントはアバターの最上位に付ける必要があります。(AvatarDescriptorのあるGameObject)"

msgid "DeleteEditorOnlyGameObjects:NotOnAvatarRoot"
msgstr "このコンポーネントはアバターの最上位に付ける必要があります。(VRChatのアバターでは、AvatarDescriptorのあるGameObject)"

# endregion

# region UnusedBonesByReferencesTool
Expand Down

0 comments on commit fc9e1df

Please sign in to comment.