Brak opisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InputActionAssetDrawer.cs 1.2KB

123456789101112131415161718192021222324252627282930
  1. // Note: If not UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS we do not use a custom property drawer and
  2. // picker for InputActionAsset but rather rely on default (classic) object picker.
  3. #if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
  4. using UnityEditor;
  5. using UnityEditor.Search;
  6. namespace UnityEngine.InputSystem.Editor
  7. {
  8. /// <summary>
  9. /// Custom property drawer in order to use the "Advanced Picker" from UnityEditor.Search.
  10. /// </summary>
  11. [CustomPropertyDrawer(typeof(InputActionAsset))]
  12. internal sealed class InputActionAssetDrawer : PropertyDrawer
  13. {
  14. private readonly SearchContext m_Context = UnityEditor.Search.SearchService.CreateContext(new[]
  15. {
  16. InputActionAssetSearchProviders.CreateInputActionAssetSearchProvider(),
  17. InputActionAssetSearchProviders.CreateInputActionAssetSearchProviderForProjectWideActions(),
  18. }, string.Empty, SearchConstants.PickerSearchFlags);
  19. public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
  20. {
  21. ObjectField.DoObjectField(position, property, typeof(InputActionAsset), label,
  22. m_Context, SearchConstants.PickerViewFlags);
  23. }
  24. }
  25. }
  26. #endif