From fc9e1dfadffbd5b460864fb6453ca4f513e40d3e Mon Sep 17 00:00:00 2001 From: kaikoga Date: Tue, 24 Oct 2023 03:58:07 +0900 Subject: [PATCH] feat: use ndmf IsAvatarRoot() for non-VRC AvatarGlobalComponent validation --- Editor/AvatarGlobalComponentEditorBase.cs | 14 +++++++++----- Localization/en.po | 3 +++ Localization/ja.po | 3 +++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Editor/AvatarGlobalComponentEditorBase.cs b/Editor/AvatarGlobalComponentEditorBase.cs index 3b942428c..75208ca58 100644 --- a/Editor/AvatarGlobalComponentEditorBase.cs +++ b/Editor/AvatarGlobalComponentEditorBase.cs @@ -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(component => { +#if AAO_VRCSDK3_AVATARS if (!component.GetComponent()) 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()) 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 } } diff --git a/Localization/en.po b/Localization/en.po index 6a4e6dc25..881394c91 100644 --- a/Localization/en.po +++ b/Localization/en.po @@ -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 diff --git a/Localization/ja.po b/Localization/ja.po index d998d4970..928e82bdf 100644 --- a/Localization/ja.po +++ b/Localization/ja.po @@ -289,6 +289,9 @@ msgstr "すべての有効/無効を入れ替える" msgid "DeleteEditorOnlyGameObjects:NotOnAvatarDescriptor" msgstr "このコンポーネントはアバターの最上位に付ける必要があります。(AvatarDescriptorのあるGameObject)" +msgid "DeleteEditorOnlyGameObjects:NotOnAvatarRoot" +msgstr "このコンポーネントはアバターの最上位に付ける必要があります。(VRChatのアバターでは、AvatarDescriptorのあるGameObject)" + # endregion # region UnusedBonesByReferencesTool