Repository URL to install this package:
Version:
1.3.1 ▾
|
using System.IO;
using Fluctio.FluctioSim.Common.Configuration;
using Fluctio.FluctioSim.EditorUtils.EditorGeneral;
using JetBrains.Annotations;
using UnityEditor;
using UnityEngine;
namespace Fluctio.FluctioSim.Common.Icons
{
public static class DefinedIcons
{
#region Functions
// Custom icons are taken from https://www.iconsdb.com/ and are allowed to use without any attribution
// https://www.iconsdb.com/custom-color/{iconFileNameWithoutExtension}-icon.html
[Pure]
private static Texture2D GetCustomIcon(params string[] pathComponents)
{
try
{
var icon = EditorUtil.LoadAsset<Texture2D>(Config.IconsFolderGuid, pathComponents);
return icon;
}
catch (FileNotFoundException)
{
EditorApplication.delayCall += EditorUtility.RequestScriptReload;
return null;
}
}
[Pure]
private static Texture2D GetBuiltinIcon(string name)
{
return (Texture2D)EditorGUIUtility.IconContent(name).image;
}
[CanBeNull]
[Pure]
public static Texture2D GetWhiteVersion(Texture2D icon)
{
var path = AssetDatabase.GetAssetPath(icon);
if (string.IsNullOrEmpty(path))
{
return null;
}
var filename = Path.GetFileNameWithoutExtension(path);
if (filename.EndsWith("_white"))
{
return icon;
}
var directory = Path.GetDirectoryName(path) ?? "";
var extension = Path.GetExtension(path);
var whitePath = Path.Combine(directory, $"{filename}_white{extension}");
var whiteIcon = AssetDatabase.LoadAssetAtPath<Texture2D>(whitePath);
return whiteIcon;
}
#endregion
#region General
public static Texture2D Logo => GetCustomIcon("Other", "logo.png");
public static Texture2D MoreComponents => GetCustomIcon("Other", "ellipsis_white.png");
public static Texture2D FilePicker => GetCustomIcon("Other", "full-folder.png");
public static Texture2D DefaultProfilePicture => GetCustomIcon("Other", "user.png");
public static Texture2D GameObject => GetBuiltinIcon("d_GameObject Icon");
#endregion
#region Dependency Status
public static Texture2D DependencyLoading => GetCustomIcon("Status", "refresh-2.png");
public static Texture2D DependencyProblem => GetCustomIcon("Status", "warning-5.png");
public static Texture2D DependencyOk => GetCustomIcon("Status", "check-mark-11.png");
#endregion
#region Mujoco Components
public static Texture2D ComponentJoint => GetCustomIcon("Components", "Mujoco", "circle-dashed-4.png");
public static Texture2D ComponentStructure => GetCustomIcon("Components", "Mujoco", "align-center.png");
public static Texture2D ComponentColor => GetCustomIcon("Components", "Mujoco", "brush-2.png");
public static Texture2D ComponentSize => GetCustomIcon("Components", "Mujoco", "resize-5.png");
public static Texture2D ComponentPhysicalProperties => GetCustomIcon("Components", "Mujoco", "atomic.png");
public static Texture2D ComponentHeightMapLayer => GetCustomIcon("Components", "Mujoco", "layers-2.png");
#endregion
#region MachineLearning Components
public static Texture2D ComponentAgent => GetCustomIcon("Components", "MachineLearning", "teacher.png");
public static Texture2D ComponentTrainingArea => GetCustomIcon("Components", "MachineLearning", "map-6.png");
public static Texture2D ComponentSensor => GetCustomIcon("Components", "MachineLearning", "antenna-5.png");
public static Texture2D ComponentActuator => GetCustomIcon("Components", "MachineLearning", "resize-10.png");
public static Texture2D ComponentRewardAdder => GetCustomIcon("Components", "MachineLearning", "arrow-up-6.png");
public static Texture2D ComponentEpisodeEnder => GetCustomIcon("Components", "MachineLearning", "flag.png");
public static Texture2D ComponentMujocoChainReseter => GetCustomIcon("Components", "MachineLearning", "undo.png");
public static Texture2D ComponentComponentEnabler => GetCustomIcon("Components", "MachineLearning", "check-mark.png");
public static Texture2D LogInfoAction => GetCustomIcon("Components", "MachineLearning", "message-2.png");
public static Texture2D ComponentRewardCalculator => GetCustomIcon("Components", "MachineLearning", "pi-sign.png");
public static Texture2D ComponentTrigger => GetCustomIcon("Components", "MachineLearning", "arrow-48.png");
public static Texture2D ComponentRandomization => GetCustomIcon("Components", "MachineLearning", "random.png");
#endregion
}
}