arenos-nexus/Arenos Nexus/Library/PackageCache/com.unity.inputsystem@be6c4fd0abf5/InputSystem/Editor/PropertyDrawers/InputActionAssetDrawer.cs

31 lines
1.2 KiB
C#
Raw Normal View History

2025-09-25 22:01:28 +02:00
// Note: If not UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS we do not use a custom property drawer and
// picker for InputActionAsset but rather rely on default (classic) object picker.
#if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
using UnityEditor;
using UnityEditor.Search;
namespace UnityEngine.InputSystem.Editor
{
/// <summary>
/// Custom property drawer in order to use the "Advanced Picker" from UnityEditor.Search.
/// </summary>
[CustomPropertyDrawer(typeof(InputActionAsset))]
internal sealed class InputActionAssetDrawer : PropertyDrawer
{
private readonly SearchContext m_Context = UnityEditor.Search.SearchService.CreateContext(new[]
{
InputActionAssetSearchProviders.CreateInputActionAssetSearchProvider(),
InputActionAssetSearchProviders.CreateInputActionAssetSearchProviderForProjectWideActions(),
}, string.Empty, SearchConstants.PickerSearchFlags);
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
ObjectField.DoObjectField(position, property, typeof(InputActionAsset), label,
m_Context, SearchConstants.PickerViewFlags);
}
}
}
#endif