modular-avatar/Packages/net.fushizen.modular-avatar/Editor/Inspector/MergeAnimationEditor.cs

68 lines
2.6 KiB
C#
Raw Normal View History

2022-10-17 05:05:26 +08:00
using UnityEditor;
using UnityEngine;
using static net.fushizen.modular_avatar.core.editor.Localization;
namespace net.fushizen.modular_avatar.core.editor
{
[CustomPropertyDrawer(typeof(MergeAnimatorPathMode))]
class PathModeDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
EditorGUI.BeginChangeCheck();
var value = EditorGUI.Popup(position, label, property.enumValueIndex, new GUIContent[]
{
G("path_mode.Relative"), G("path_mode.Absolute")
});
if (EditorGUI.EndChangeCheck())
{
property.enumValueIndex = value;
}
EditorGUI.EndProperty();
}
}
[CustomEditor(typeof(ModularAvatarMergeAnimator))]
class MergeAnimationEditor : Editor
{
private SerializedProperty prop_animator,
prop_layerType,
prop_deleteAttachedAnimator,
prop_pathMode,
prop_matchAvatarWriteDefaults;
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));
}
public override void OnInspectorGUI()
{
2022-10-23 04:31:10 +08:00
LogoDisplay.DisplayLogo();
InspectorCommon.DisplayOutOfAvatarWarning(targets);
2022-10-23 04:31:10 +08:00
2022-10-17 05:05:26 +08: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"));
EditorGUILayout.PropertyField(prop_matchAvatarWriteDefaults,
G("merge_animator.match_avatar_write_defaults"));
serializedObject.ApplyModifiedProperties();
ShowLanguageUI();
}
}
}