-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace UnityAtoms | ||
{ | ||
/// <summary> | ||
/// Use in order to determine if this is a GameAction when assigning icons to Atoms. | ||
/// This is hack is necessary because IsAssignableFrom and IsSubclassOf doesn't work without a type constraint 💩 | ||
/// </summary> | ||
public interface IGameActionIcon { } | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace UnityAtoms | ||
{ | ||
/// <summary> | ||
/// Use in order to determine if this is a Constant when assigning icons to Atoms. | ||
/// This is hack is necessary because IsAssignableFrom and IsSubclassOf doesn't work without a type constraint 💩 | ||
/// </summary> | ||
public interface IConstantIcon { } | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace UnityAtoms | ||
{ | ||
/// <summary> | ||
/// Use in order to determine if this is a Event when assigning icons to Atoms. | ||
/// This is hack is necessary because IsAssignableFrom and IsSubclassOf doesn't work without a type constraint 💩 | ||
/// </summary> | ||
public interface IEventIcon { } | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace UnityAtoms | ||
{ | ||
/// <summary> | ||
/// Use in order to determine if this is a Function when assigning icons to Atoms. | ||
/// This is hack is necessary because IsAssignableFrom and IsSubclassOf doesn't work without a type constraint 💩 | ||
/// </summary> | ||
public interface IFunctionIcon { } | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace UnityAtoms | ||
{ | ||
internal class AtomsIconAssignmentProcessor : IconAssignmentProcessor | ||
{ | ||
protected override string IconSearchPath | ||
{ | ||
get => System.Environment.CurrentDirectory.Contains("unity-atoms/UnityAtomsTestsAndExamples") ? | ||
Directory.GetParent(Directory.GetParent(Application.dataPath).FullName).FullName : | ||
Directory.GetParent(Application.dataPath).FullName; | ||
} | ||
protected override string IconSearchFilter { get => "atom-icon-"; } | ||
protected override string SettingsPath { get => $"{Application.dataPath}{Path.DirectorySeparatorChar}UnityAtomsIconSettings.json"; } | ||
protected override List<IIconAssigner> IconAssigners { get => new List<IIconAssigner>() { new AtomMonoScriptAssigner() }; } | ||
} | ||
|
||
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) | ||
{ | ||
if (typeof(IGameActionIcon).IsAssignableFrom(type)) | ||
{ | ||
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-purple"); | ||
} | ||
else if (typeof(IVariableIcon).IsAssignableFrom(type)) | ||
{ | ||
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-orange"); | ||
} | ||
else if (typeof(IConstantIcon).IsAssignableFrom(type)) | ||
{ | ||
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-teal"); | ||
} | ||
else if (typeof(IEventIcon).IsAssignableFrom(type)) | ||
{ | ||
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-teal"); | ||
} | ||
else if (typeof(IFunctionIcon).IsAssignableFrom(type)) | ||
{ | ||
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-lush"); | ||
} | ||
else if (typeof(IListenerIcon).IsAssignableFrom(type)) | ||
{ | ||
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-piglet"); | ||
} | ||
else if (typeof(IListIcon).IsAssignableFrom(type)) | ||
{ | ||
return icons.FirstOrDefault((icon) => icon.Name == "atom-icon-pinky"); | ||
} | ||
} | ||
return null; | ||
}; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace UnityAtoms | ||
{ | ||
public interface IIconAssigner | ||
{ | ||
void Assign(string assetPath, List<IconData> icons, IconAssigmentSettings settings); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace UnityAtoms | ||
{ | ||
[Serializable] | ||
public class IconAssigmentSetting | ||
{ | ||
public IconAssigmentSetting(string assetPath, string iconPath) | ||
{ | ||
AssetPath = assetPath; | ||
IconPath = iconPath; | ||
} | ||
|
||
public string AssetPath; | ||
public string IconPath; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.