2024-12-11 07:55:57 +08:00
using UnityEditor ;
2024-05-03 21:21:21 +08:00
using UnityEngine ;
2024-05-04 01:29:32 +08:00
namespace DCFApixels.DragonECS.Unity.Internal
2024-05-03 21:21:21 +08:00
{
2024-05-04 01:29:32 +08:00
internal class Icons : Config < Icons >
2024-05-03 21:21:21 +08:00
{
2024-06-13 18:04:47 +08:00
//Everything inside #if UNITY_EDITOR is not serialized in the release build
2024-05-04 01:29:32 +08:00
#if UNITY_EDITOR
2024-05-03 21:21:21 +08:00
[SerializeField]
2024-06-25 23:33:46 +08:00
private Texture _helpIcon = null ;
2024-05-03 21:21:21 +08:00
[SerializeField]
2024-10-01 18:04:53 +08:00
private Texture _fileIcon = null ;
2024-10-12 14:37:21 +08:00
[SerializeField]
private Texture _metaIDIcon = null ;
2024-10-19 00:05:07 +08:00
[SerializeField]
private Texture _repaireIcon = null ;
2024-10-01 18:04:53 +08:00
2024-05-03 21:21:21 +08:00
[SerializeField]
2024-10-01 18:04:53 +08:00
private Texture _errorIcon = null ;
[SerializeField]
private Texture _warningIcon = null ;
[SerializeField]
private Texture _passIcon = null ;
2024-05-03 21:21:21 +08:00
[SerializeField]
2024-06-25 23:33:46 +08:00
private Texture _unlinkIcon = null ;
2024-05-03 21:21:21 +08:00
[SerializeField]
2024-10-01 18:04:53 +08:00
private Texture _searchIcon = null ;
[SerializeField]
private Texture _closeIcon = null ;
[SerializeField]
private Texture _closeIconOn = null ;
[SerializeField]
2024-06-25 23:33:46 +08:00
private Texture _auotsetIcon = null ;
2024-05-03 21:21:21 +08:00
[SerializeField]
2024-06-25 23:33:46 +08:00
private Texture _auotsetCascadeIcon = null ;
2024-06-13 18:04:47 +08:00
[SerializeField]
2024-06-25 23:33:46 +08:00
private Texture _visibilityIconOn = null ;
2024-06-13 18:04:47 +08:00
[SerializeField]
2024-06-25 23:33:46 +08:00
private Texture _visibilityIconOff = null ;
2024-06-13 18:04:47 +08:00
[SerializeField]
2024-06-25 23:33:46 +08:00
private Texture _labelIconType = null ;
2024-06-13 18:04:47 +08:00
[SerializeField]
2024-06-25 23:33:46 +08:00
private Texture _labelIconMeta = null ;
2024-10-01 18:04:53 +08:00
2024-06-13 18:04:47 +08:00
2024-12-10 21:09:29 +08:00
private Texture2D _dummy ;
private Texture2D _dummyRed ;
private Texture2D _dummyGreen ;
private Texture2D _dummyYellow ;
2024-10-01 18:04:53 +08:00
2024-12-10 21:09:29 +08:00
private Texture2D Dummy
{
get { InitDummies ( ) ; return _dummy ; }
}
private Texture2D DummyRed
{
get { InitDummies ( ) ; return _dummyRed ; }
}
private Texture2D DummyGreen
{
get { InitDummies ( ) ; return _dummyGreen ; }
}
private Texture2D DummyYellow
{
get { InitDummies ( ) ; return _dummyYellow ; }
}
2024-10-01 18:04:53 +08:00
2024-12-10 21:09:29 +08:00
private void InitDummies ( )
{
if ( _dummy ! = null ) { return ; }
EcsDebug . PrintWarning ( "Some icons are missing. The issue might be resolved by using \"Assets -> Reimport All\" or by deleting the \"*project_name*/Library\" folder and restarting Unity." ) ;
2024-12-11 07:55:57 +08:00
try
{
string json = JsonUtility . ToJson ( CreateInstance ( typeof ( Icons ) ) ) ;
JsonUtility . FromJsonOverwrite ( json , this ) ;
EditorUtility . SetDirty ( this ) ;
}
catch { }
2024-12-10 21:09:29 +08:00
Texture2D Create ( Color color_ )
{
Texture2D result_ = new Texture2D ( 2 , 2 ) ;
for ( int i = 0 ; i < 2 ; i + + )
{
for ( int j = 0 ; j < 2 ; j + + )
{
result_ . SetPixel ( i , j , color_ ) ;
}
}
result_ . Apply ( ) ;
return result_ ;
}
_dummy = Create ( Color . white ) ;
_dummyRed = Create ( Color . red ) ;
_dummyGreen = Create ( Color . green ) ;
_dummyYellow = Create ( Color . yellow ) ;
}
2024-12-11 07:55:57 +08:00
internal Texture HelpIcon { get { return _helpIcon ! = null ? _helpIcon : Dummy ; } }
internal Texture FileIcon { get { return _fileIcon ! = null ? _fileIcon : Dummy ; } }
internal Texture MetaIDIcon { get { return _metaIDIcon ! = null ? _metaIDIcon : Dummy ; } }
internal Texture RepaireIcon { get { return _repaireIcon ! = null ? _repaireIcon : Dummy ; } }
2024-12-10 21:09:29 +08:00
2024-12-11 07:55:57 +08:00
internal Texture ErrorIcon { get { return _errorIcon ! = null ? _errorIcon : DummyRed ; } }
internal Texture WarningIcon { get { return _warningIcon ! = null ? _warningIcon : DummyYellow ; } }
internal Texture PassIcon { get { return _passIcon ! = null ? _passIcon : DummyGreen ; } }
2024-12-10 21:09:29 +08:00
2024-12-11 07:55:57 +08:00
internal Texture UnlinkIcon { get { return _unlinkIcon ! = null ? _unlinkIcon : Dummy ; } }
internal Texture SearchIcon { get { return _searchIcon ! = null ? _searchIcon : Dummy ; } }
internal Texture CloseIcon { get { return _closeIcon ! = null ? _closeIcon : DummyRed ; } }
internal Texture CloseIconOn { get { return _closeIconOn ! = null ? _closeIconOn : DummyRed ; } }
internal Texture AuotsetIcon { get { return _auotsetIcon ! = null ? _auotsetIcon : Dummy ; } }
internal Texture AutosetCascadeIcon { get { return _auotsetCascadeIcon ! = null ? _auotsetCascadeIcon : Dummy ; } }
internal Texture VisibilityIconOn { get { return _visibilityIconOn ! = null ? _visibilityIconOn : Dummy ; } }
internal Texture VisibilityIconOff { get { return _visibilityIconOff ! = null ? _visibilityIconOff : Dummy ; } }
internal Texture LabelIconType { get { return _labelIconType ! = null ? _labelIconType : Dummy ; } }
internal Texture LabelIconMeta { get { return _labelIconMeta ! = null ? _labelIconMeta : Dummy ; } }
2024-05-04 01:29:32 +08:00
#endif
2024-05-03 21:21:21 +08:00
}
2024-12-10 21:09:29 +08:00
}