OutlineSettingsExtensions.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright (C) 2019-2021 Alexander Bogarsukov. All rights reserved.
  2. // See the LICENSE.md file in the project root for more information.
  3. using System;
  4. using System.ComponentModel;
  5. using System.Runtime.CompilerServices;
  6. using UnityEngine;
  7. namespace UnityFx.Outline
  8. {
  9. /// <summary>
  10. /// Extension methods for <see cref="IOutlineSettings"/>.
  11. /// </summary>
  12. [EditorBrowsable(EditorBrowsableState.Never)]
  13. public static class OutlineSettingsExtensions
  14. {
  15. /// <summary>
  16. /// Gets a value indicating whether outline should use alpha testing.
  17. /// </summary>
  18. /// <seealso cref="IsDepthTestingEnabled(IOutlineSettings)"/>
  19. /// <seealso cref="IsBlurEnabled(IOutlineSettings)"/>
  20. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  21. public static bool IsAlphaTestingEnabled(this IOutlineSettings settings)
  22. {
  23. return (settings.OutlineRenderMode & OutlineRenderFlags.EnableAlphaTesting) != 0;
  24. }
  25. /// <summary>
  26. /// Gets a value indicating whether outline should use depth testing.
  27. /// </summary>
  28. /// <seealso cref="IsAlphaTestingEnabled(IOutlineSettings)"/>
  29. /// <seealso cref="IsBlurEnabled(IOutlineSettings)"/>
  30. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  31. public static bool IsDepthTestingEnabled(this IOutlineSettings settings)
  32. {
  33. return (settings.OutlineRenderMode & OutlineRenderFlags.EnableDepthTesting) != 0;
  34. }
  35. /// <summary>
  36. /// Gets a value indicating whether outline frame should be blurred.
  37. /// </summary>
  38. /// <seealso cref="IsAlphaTestingEnabled(IOutlineSettings)"/>
  39. /// <seealso cref="IsDepthTestingEnabled(IOutlineSettings)"/>
  40. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  41. public static bool IsBlurEnabled(this IOutlineSettings settings)
  42. {
  43. return (settings.OutlineRenderMode & OutlineRenderFlags.Blurred) != 0;
  44. }
  45. }
  46. }