Add AtomsSearchable attribute to indentify searchable atoms and apply to BaseAtom (#216)

This commit is contained in:
Adam Ramberg 2020-12-22 21:18:46 +01:00 committed by GitHub
parent 7356e78bc3
commit 3c74509b5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 2 deletions

View File

@ -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('/');

View 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 { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 758696991edcb4227bd2cba325398e0c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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)

View File

@ -5,6 +5,7 @@ namespace UnityAtoms
/// <summary>
/// None generic base class for all Atoms.
/// </summary>
[AtomsSearchable]
public abstract class BaseAtom : ScriptableObject
{
/// <summary>