// Animancer // https://kybernetik.com.au/animancer // Copyright 2018-2024 Kybernetik // #if UNITY_EDITOR using UnityEditor; using UnityEngine; namespace Animancer.Editor { /// [Editor-Only] Icon textures used throughout Animancer. /// https://kybernetik.com.au/animancer/api/Animancer.Editor/AnimancerIcons public static class AnimancerIcons { /************************************************************************************************************************/ /// A standard icon for information. public static readonly Texture Info = Load("console.infoicon"); /// A standard icon for warnings. public static readonly Texture Warning = Load("console.warnicon"); /// A standard icon for errors. public static readonly Texture Error = Load("console.erroricon"); /************************************************************************************************************************/ private static Texture _ScriptableObject; /// The icon for . public static Texture ScriptableObject { get { if (_ScriptableObject == null) { _ScriptableObject = Load("d_ScriptableObject Icon"); if (_ScriptableObject == null) _ScriptableObject = AssetPreview.GetMiniTypeThumbnail(typeof(StringAsset)); } return _ScriptableObject; } } /************************************************************************************************************************/ /// Loads an icon texture. public static Texture Load(string name, FilterMode filterMode = FilterMode.Bilinear) { var icon = EditorGUIUtility.Load(name) as Texture; if (icon != null) icon.filterMode = filterMode; return icon; } /// Loads an icon `texture` if it was null. public static Texture Load(ref Texture texture, string name, FilterMode filterMode = FilterMode.Bilinear) => texture != null ? texture : texture = Load(name, filterMode); /************************************************************************************************************************/ private static GUIContent _PlayIcon, _PauseIcon, _StepBackwardIcon, _StepForwardIcon, _AddIcon, _ClearIcon, _CopyIcon; /// for a play button. public static GUIContent PlayIcon => IconContent(ref _PlayIcon, "PlayButton"); /// for a pause button. public static GUIContent PauseIcon => IconContent(ref _PauseIcon, "PauseButton"); /// for a step backward button. public static GUIContent StepBackwardIcon => IconContent(ref _StepBackwardIcon, "Animation.PrevKey"); /// for a step forward button. public static GUIContent StepForwardIcon => IconContent(ref _StepForwardIcon, "Animation.NextKey"); /// for an add button. public static GUIContent AddIcon(string tooltip = "Add") => IconContent(ref _AddIcon, "Toolbar Plus", tooltip); /// for a clear button. public static GUIContent ClearIcon(string tooltip = "Clear") => IconContent(ref _ClearIcon, "Grid.EraserTool", tooltip); /// for a copy button. public static GUIContent CopyIcon(string tooltip = "Copy to clipboard") => IconContent(ref _CopyIcon, "UnityEditor.ConsoleWindow", tooltip); /************************************************************************************************************************/ /// Calls if the `content` was null. public static GUIContent IconContent(ref GUIContent content, string name, string tooltip = "") { content ??= EditorGUIUtility.IconContent(name); content.tooltip = tooltip; return content; } /************************************************************************************************************************/ } } #endif