mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-22 08:08:51 -05:00
Add AtomsSearchable attribute to indentify searchable atoms and apply to BaseAtom (#216)
This commit is contained in:
parent
7356e78bc3
commit
3c74509b5a
@ -39,7 +39,7 @@ namespace UnityAtoms.Editor
|
||||
StringTree<Type> typeTree = new StringTree<Type>();
|
||||
|
||||
foreach (var type in TypeCache.GetTypesWithAttribute<CreateAssetMenuAttribute>()
|
||||
.Where(t => t.Namespace != null && t.Namespace.Contains("Atom")))
|
||||
.Where(t => t.GetCustomAttribute<AtomsSearchable>(true) != null))
|
||||
{
|
||||
var name = type.GetCustomAttribute<CreateAssetMenuAttribute>().menuName;
|
||||
var i = name.LastIndexOf('/');
|
||||
|
10
Packages/Core/Runtime/Attributes/AtomsSearchableAttribute.cs
Normal file
10
Packages/Core/Runtime/Attributes/AtomsSearchableAttribute.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace UnityAtoms
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute that makes an Atom searchable.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
|
||||
public class AtomsSearchable : Attribute { }
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 758696991edcb4227bd2cba325398e0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -5,7 +5,7 @@ namespace UnityAtoms
|
||||
/// <summary>
|
||||
/// Specify a texture name from your assets which you want to be assigned as an icon to the MonoScript.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = false)]
|
||||
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
|
||||
public class EditorIcon : Attribute
|
||||
{
|
||||
public EditorIcon(string name)
|
||||
|
@ -5,6 +5,7 @@ namespace UnityAtoms
|
||||
/// <summary>
|
||||
/// None generic base class for all Atoms.
|
||||
/// </summary>
|
||||
[AtomsSearchable]
|
||||
public abstract class BaseAtom : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user