#if MA_VRCSDK3_AVATARS && UNITY_2022_1_OR_NEWER using System; using UnityEditor; using UnityEngine.UIElements; using Toggle = UnityEngine.UIElements.Toggle; namespace nadena.dev.modular_avatar.core.editor.Parameters { [CustomPropertyDrawer(typeof(ParameterConfig))] internal class ParameterConfigDrawer : PropertyDrawer { public override VisualElement CreatePropertyGUI(SerializedProperty property) { var rootPath = "Packages/nadena.dev.modular-avatar/Editor/Inspector/Parameters"; var uss = AssetDatabase.LoadAssetAtPath(rootPath + "/Parameters.uss"); var uxml = AssetDatabase.LoadAssetAtPath(rootPath + "/ParameterConfigDrawer.uxml"); var root = uxml.CloneTree(); Localization.UI.Localize(root); root.styleSheets.Add(uss); var type_field = root.Q("f-type"); var f_sync_type = root.Q("f-sync-type"); SetupPairedDropdownField( root, type_field, f_sync_type, root.Q("f-is-prefix"), ("Bool", "False", "params.syncmode.Bool"), ("Float", "False", "params.syncmode.Float"), ("Int", "False", "params.syncmode.Int"), ("Not Synced", "False", "params.syncmode.NotSynced"), (null, "True", "params.syncmode.PhysBonesPrefix") ); f_sync_type.Q().RegisterValueChangedCallback(evt => { var is_anim_only = evt.newValue == "Not Synced"; if (is_anim_only) root.AddToClassList("st-anim-only"); else root.RemoveFromClassList("st-anim-only"); }); var f_synced = root.Q("f-synced"); var f_local_only = root.Q("f-local-only"); // Invert f_local_only and f_synced f_local_only.RegisterValueChangedCallback(evt => { f_synced.SetValueWithoutNotify(!evt.newValue); }); f_synced.RegisterValueChangedCallback(evt => { f_local_only.value = !evt.newValue; }); var internalParamAccessor = root.Q("f-internal-parameter"); internalParamAccessor.RegisterValueChangedCallback(evt => { if (evt.newValue) root.AddToClassList("st-internal-parameter"); else root.RemoveFromClassList("st-internal-parameter"); }); root.Q("remap-to-group-disabled").SetEnabled(false); var name = root.Q("f-name"); var remapTo = root.Q("f-remap-to"); var remapToInner = remapTo.Q(); var remapToPlaceholder = root.Q