modular-avatar/Editor/Inspector/MergeAnimationEditor.cs

72 lines
3.2 KiB
C#
Raw Normal View History

#if MA_VRCSDK3_AVATARS
using UnityEditor;
2022-11-10 20:39:58 -08:00
using static nadena.dev.modular_avatar.core.editor.Localization;
2022-10-16 14:05:26 -07:00
2022-11-10 20:39:58 -08:00
namespace nadena.dev.modular_avatar.core.editor
2022-10-16 14:05:26 -07:00
{
[CustomPropertyDrawer(typeof(MergeAnimatorPathMode))]
class PathModeDrawer : EnumDrawer<MergeAnimatorPathMode>
2022-10-16 14:05:26 -07:00
{
protected override string localizationPrefix => "path_mode";
2022-10-16 14:05:26 -07:00
}
[CustomPropertyDrawer(typeof(MergeAnimatorMode))]
internal class MergeModeDrawer : EnumDrawer<MergeAnimatorMode>
{
protected override string localizationPrefix => "merge_animator.merge_mode";
}
2022-10-16 14:05:26 -07:00
[CustomEditor(typeof(ModularAvatarMergeAnimator))]
class MergeAnimationEditor : MAEditorBase
2022-10-16 14:05:26 -07:00
{
private SerializedProperty prop_animator,
prop_layerType,
prop_deleteAttachedAnimator,
prop_pathMode,
prop_matchAvatarWriteDefaults,
prop_relativePathRoot,
prop_layerPriority,
prop_mergeMode;
2022-10-16 14:05:26 -07:00
private void OnEnable()
{
prop_animator = serializedObject.FindProperty(nameof(ModularAvatarMergeAnimator.animator));
prop_layerType = serializedObject.FindProperty(nameof(ModularAvatarMergeAnimator.layerType));
prop_deleteAttachedAnimator =
serializedObject.FindProperty(nameof(ModularAvatarMergeAnimator.deleteAttachedAnimator));
prop_pathMode = serializedObject.FindProperty(nameof(ModularAvatarMergeAnimator.pathMode));
prop_matchAvatarWriteDefaults =
serializedObject.FindProperty(nameof(ModularAvatarMergeAnimator.matchAvatarWriteDefaults));
prop_relativePathRoot =
serializedObject.FindProperty(nameof(ModularAvatarMergeAnimator.relativePathRoot));
prop_layerPriority = serializedObject.FindProperty(nameof(ModularAvatarMergeAnimator.layerPriority));
prop_mergeMode = serializedObject.FindProperty(nameof(ModularAvatarMergeAnimator.mergeAnimatorMode));
2022-10-16 14:05:26 -07:00
}
protected override void OnInnerInspectorGUI()
2022-10-16 14:05:26 -07:00
{
serializedObject.Update();
EditorGUILayout.PropertyField(prop_animator, G("merge_animator.animator"));
EditorGUILayout.PropertyField(prop_layerType, G("merge_animator.layer_type"));
EditorGUILayout.PropertyField(prop_deleteAttachedAnimator, G("merge_animator.delete_attached_animator"));
EditorGUILayout.PropertyField(prop_pathMode, G("merge_animator.path_mode"));
if (prop_pathMode.enumValueIndex == (int) MergeAnimatorPathMode.Relative)
EditorGUILayout.PropertyField(prop_relativePathRoot, G("merge_animator.relative_path_root"));
EditorGUILayout.PropertyField(prop_layerPriority, G("merge_animator.layer_priority"));
EditorGUILayout.PropertyField(prop_mergeMode, G("merge_animator.merge_mode"));
using (new EditorGUI.DisabledScope(prop_mergeMode.enumValueIndex == (int)MergeAnimatorMode.Replace))
{
EditorGUILayout.PropertyField(prop_matchAvatarWriteDefaults,
G("merge_animator.match_avatar_write_defaults"));
}
2022-10-16 14:05:26 -07:00
serializedObject.ApplyModifiedProperties();
ShowLanguageUI();
}
}
}
#endif