Tri-Inspector/Editor/Utilities/TriAttributeUtilities.cs

24 lines
576 B
C#
Raw Normal View History

2021-12-07 10:20:36 -05:00
using System;
using System.Collections.Generic;
namespace TriInspector.Utilities
{
internal static class TriAttributeUtilities
{
public static bool TryGet<T>(this IReadOnlyList<Attribute> attributes, out T it)
where T : Attribute
{
foreach (var attribute in attributes)
{
if (attribute is T typeAttribute)
{
it = typeAttribute;
return true;
}
}
it = null;
return false;
}
}
}