2023-08-22 17:44:02 +08:00
|
|
|
|
using UnityEditor;
|
2022-10-04 09:29:49 +08:00
|
|
|
|
using UnityEngine;
|
2022-11-11 12:39:58 +08:00
|
|
|
|
using static nadena.dev.modular_avatar.core.editor.Localization;
|
2022-10-04 09:29:49 +08:00
|
|
|
|
|
2022-11-11 12:39:58 +08:00
|
|
|
|
namespace nadena.dev.modular_avatar.core.editor
|
2022-10-04 09:29:49 +08:00
|
|
|
|
{
|
|
|
|
|
[CustomEditor(typeof(ModularAvatarMergeArmature))]
|
2022-11-11 12:30:10 +08:00
|
|
|
|
internal class MergeArmatureEditor : MAEditorBase
|
2022-10-04 09:29:49 +08:00
|
|
|
|
{
|
2023-07-29 17:04:59 +08:00
|
|
|
|
private SerializedProperty prop_mergeTarget, prop_prefix, prop_suffix, prop_locked, prop_mangleNames;
|
2022-10-17 05:05:26 +08:00
|
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
prop_mergeTarget = serializedObject.FindProperty(nameof(ModularAvatarMergeArmature.mergeTarget));
|
|
|
|
|
prop_prefix = serializedObject.FindProperty(nameof(ModularAvatarMergeArmature.prefix));
|
|
|
|
|
prop_suffix = serializedObject.FindProperty(nameof(ModularAvatarMergeArmature.suffix));
|
|
|
|
|
prop_locked = serializedObject.FindProperty(nameof(ModularAvatarMergeArmature.locked));
|
2023-07-29 17:04:59 +08:00
|
|
|
|
prop_mangleNames = serializedObject.FindProperty(nameof(ModularAvatarMergeArmature.mangleNames));
|
2022-10-17 05:05:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ShowParametersUI()
|
|
|
|
|
{
|
|
|
|
|
serializedObject.Update();
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.PropertyField(prop_mergeTarget, G("merge_armature.merge_target"));
|
|
|
|
|
EditorGUILayout.PropertyField(prop_prefix, G("merge_armature.prefix"));
|
|
|
|
|
EditorGUILayout.PropertyField(prop_suffix, G("merge_armature.suffix"));
|
2023-07-29 17:04:59 +08:00
|
|
|
|
EditorGUILayout.PropertyField(prop_mangleNames, G("merge_armature.mangle_names"));
|
2022-10-17 05:05:26 +08:00
|
|
|
|
EditorGUILayout.PropertyField(prop_locked, G("merge_armature.locked"));
|
|
|
|
|
|
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-11 12:30:10 +08:00
|
|
|
|
protected override void OnInnerInspectorGUI()
|
2022-10-04 09:29:49 +08:00
|
|
|
|
{
|
|
|
|
|
var target = (ModularAvatarMergeArmature) this.target;
|
|
|
|
|
var priorMergeTarget = target.mergeTargetObject;
|
|
|
|
|
|
|
|
|
|
EditorGUI.BeginChangeCheck();
|
2022-10-17 05:05:26 +08:00
|
|
|
|
ShowParametersUI();
|
2022-10-04 09:29:49 +08:00
|
|
|
|
if (EditorGUI.EndChangeCheck())
|
|
|
|
|
{
|
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
|
|
|
|
|
|
if (target.mergeTargetObject != null && priorMergeTarget == null
|
|
|
|
|
&& string.IsNullOrEmpty(target.prefix)
|
|
|
|
|
&& string.IsNullOrEmpty(target.suffix))
|
|
|
|
|
{
|
2022-10-05 10:43:46 +08:00
|
|
|
|
target.InferPrefixSuffix();
|
2022-10-04 09:29:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-17 05:05:26 +08:00
|
|
|
|
|
2022-12-10 12:33:05 +08:00
|
|
|
|
var enable_name_assignment =
|
|
|
|
|
target.mergeTarget.Get(RuntimeUtil.FindAvatarInParents(target.transform)) != null;
|
|
|
|
|
using (var scope = new EditorGUI.DisabledScope(!enable_name_assignment))
|
|
|
|
|
{
|
|
|
|
|
if (GUILayout.Button(G("merge_armature.adjust_names")))
|
|
|
|
|
{
|
|
|
|
|
HeuristicBoneMapper.RenameBonesByHeuristic(target);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-17 05:05:26 +08:00
|
|
|
|
Localization.ShowLanguageUI();
|
2022-10-04 09:29:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|