2019-06-16 15:27:24 -04:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
|
|
namespace UnityAtoms
|
|
|
|
{
|
2019-06-23 16:09:21 -04:00
|
|
|
/// <summary>
|
|
|
|
/// Custom icon assigner for Unity Atoms.
|
|
|
|
/// </summary>
|
2019-06-16 15:27:24 -04:00
|
|
|
internal class AtomMonoScriptAssigner : IconAssigner<MonoScript>
|
|
|
|
{
|
|
|
|
protected override Func<MonoScript, List<IconData>, IconData> SelectIcon
|
|
|
|
{
|
|
|
|
get => (script, icons) =>
|
|
|
|
{
|
|
|
|
var type = script?.GetClass();
|
|
|
|
var scriptName = type?.Name;
|
|
|
|
var inUnityAtomsNS = scriptName != null && type != null && type.Namespace != null && type.Namespace.StartsWith("UnityAtoms");
|
|
|
|
if (inUnityAtomsNS)
|
|
|
|
{
|
2019-09-25 15:05:06 -04:00
|
|
|
if (typeof(IAtomActionIcon).IsAssignableFrom(type))
|
2019-06-16 15:27:24 -04:00
|
|
|
{
|
|
|
|
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-purple");
|
|
|
|
}
|
2019-09-25 15:05:06 -04:00
|
|
|
else if (typeof(IAtomVariableIcon).IsAssignableFrom(type))
|
2019-06-16 15:27:24 -04:00
|
|
|
{
|
2019-06-16 17:41:19 -04:00
|
|
|
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-lush");
|
2019-06-16 15:27:24 -04:00
|
|
|
}
|
2019-09-25 15:05:06 -04:00
|
|
|
else if (typeof(IAtomConstantIcon).IsAssignableFrom(type))
|
2019-06-16 15:27:24 -04:00
|
|
|
{
|
|
|
|
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-teal");
|
|
|
|
}
|
2019-09-25 15:05:06 -04:00
|
|
|
else if (typeof(IAtomEventIcon).IsAssignableFrom(type))
|
2019-06-16 15:27:24 -04:00
|
|
|
{
|
2019-06-16 17:41:19 -04:00
|
|
|
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-cherry");
|
2019-06-16 15:27:24 -04:00
|
|
|
}
|
2019-09-25 15:05:06 -04:00
|
|
|
else if (typeof(IAtomFunctionIcon).IsAssignableFrom(type))
|
2019-06-16 15:27:24 -04:00
|
|
|
{
|
2019-06-16 17:41:19 -04:00
|
|
|
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-sand");
|
2019-06-16 15:27:24 -04:00
|
|
|
}
|
2019-09-25 15:05:06 -04:00
|
|
|
else if (typeof(IAtomListenerIcon).IsAssignableFrom(type))
|
2019-06-16 15:27:24 -04:00
|
|
|
{
|
|
|
|
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-piglet");
|
|
|
|
}
|
2019-09-25 15:05:06 -04:00
|
|
|
else if (typeof(IAtomListIcon).IsAssignableFrom(type))
|
2019-06-16 15:27:24 -04:00
|
|
|
{
|
2019-06-16 17:41:19 -04:00
|
|
|
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-orange");
|
2019-06-16 15:27:24 -04:00
|
|
|
}
|
2019-06-16 17:41:19 -04:00
|
|
|
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-delicate");
|
2019-06-16 15:27:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|