#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 f_type = root.Q("f-type"); var f_sync_type = root.Q("f-sync-type"); var f_is_prefix = root.Q("f-is-prefix"); SetupPairedDropdownField( root, f_type, f_sync_type, 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") ); var f_default = root.Q(); f_default.OnUpdateSyncType((ParameterSyncType)f_sync_type.index); f_sync_type.RegisterValueChangedCallback(evt => f_default.OnUpdateSyncType((ParameterSyncType)f_sync_type.index)); 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