From 6c4c0afb0647f4bbe622a598b7400dd719f6615b Mon Sep 17 00:00:00 2001 From: bd_ Date: Tue, 27 Feb 2024 02:27:24 -0800 Subject: [PATCH] fix: change attachment mode causes non-undoable transform movement (#710) Closes: #655 --- Editor/Inspector/BoneProxyEditor.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Editor/Inspector/BoneProxyEditor.cs b/Editor/Inspector/BoneProxyEditor.cs index fdd23481..f9d3ec6d 100644 --- a/Editor/Inspector/BoneProxyEditor.cs +++ b/Editor/Inspector/BoneProxyEditor.cs @@ -1,9 +1,13 @@ -using System; +#region + +using System; using UnityEditor; using UnityEngine; using static nadena.dev.modular_avatar.core.editor.Localization; using Object = UnityEngine.Object; +#endregion + namespace nadena.dev.modular_avatar.core.editor { internal class TempObjRef : ScriptableObject @@ -104,7 +108,18 @@ namespace nadena.dev.modular_avatar.core.editor serializedObject.UpdateIfRequiredOrScript(); var p_attachmentMode = serializedObject.FindProperty(nameof(ModularAvatarBoneProxy.attachmentMode)); + EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(p_attachmentMode, G("boneproxy.attachment")); + if (EditorGUI.EndChangeCheck()) + { + serializedObject.ApplyModifiedProperties(); + foreach (var target in targets) + { + var t = (ModularAvatarBoneProxy)target; + Undo.RecordObject(t.transform, ""); + t.Update(); + } + } foldout = EditorGUILayout.Foldout(foldout, G("boneproxy.foldout.advanced")); if (foldout) @@ -122,7 +137,7 @@ namespace nadena.dev.modular_avatar.core.editor serializedObject.ApplyModifiedProperties(); - Localization.ShowLanguageUI(); + ShowLanguageUI(); } private void CheckAttachmentMode(ModularAvatarBoneProxy boneProxy)