From 58d75d4faa4e9de58f244268296d9ca2754445a9 Mon Sep 17 00:00:00 2001 From: ByteWarsJedi <99481254+DCFApixels@users.noreply.github.com> Date: Wed, 11 Dec 2024 07:55:57 +0800 Subject: [PATCH] fix icon missings --- src/Internal/Icons/Icons.cs | 48 +++++++++++++----------- src/Internal/Icons/Resources/Icons.asset | 28 +++++++------- 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/Internal/Icons/Icons.cs b/src/Internal/Icons/Icons.cs index 7306901..2e989d5 100644 --- a/src/Internal/Icons/Icons.cs +++ b/src/Internal/Icons/Icons.cs @@ -1,3 +1,4 @@ +using UnityEditor; using UnityEngine; namespace DCFApixels.DragonECS.Unity.Internal @@ -70,6 +71,14 @@ namespace DCFApixels.DragonECS.Unity.Internal { 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."); + try + { + string json = JsonUtility.ToJson(CreateInstance(typeof(Icons))); + JsonUtility.FromJsonOverwrite(json, this); + EditorUtility.SetDirty(this); + } + catch { } + Texture2D Create(Color color_) { Texture2D result_ = new Texture2D(2, 2); @@ -89,30 +98,25 @@ namespace DCFApixels.DragonECS.Unity.Internal _dummyYellow = Create(Color.yellow); } - private static Texture Return(Texture icon, Texture dummy) - { - return icon == null ? dummy : icon; - } + 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; } } - internal Texture HelpIcon { get { return Return(_helpIcon, Dummy); } } - internal Texture FileIcon { get { return Return(_fileIcon, Dummy); } } - internal Texture MetaIDIcon { get { return Return(_metaIDIcon, Dummy); } } - internal Texture RepaireIcon { get { return Return(_repaireIcon, Dummy); } } + 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; } } - internal Texture ErrorIcon { get { return Return(_errorIcon, DummyRed); } } - internal Texture WarningIcon { get { return Return(_warningIcon, DummyYellow); } } - internal Texture PassIcon { get { return Return(_passIcon, DummyGreen); } } - - internal Texture UnlinkIcon { get { return Return(_unlinkIcon, Dummy); } } - internal Texture SearchIcon { get { return Return(_searchIcon, Dummy); } } - internal Texture CloseIcon { get { return Return(_closeIcon, DummyRed); } } - internal Texture CloseIconOn { get { return Return(_closeIconOn, DummyRed); } } - internal Texture AuotsetIcon { get { return Return(_auotsetIcon, Dummy); } } - internal Texture AutosetCascadeIcon { get { return Return(_auotsetCascadeIcon, Dummy); } } - internal Texture VisibilityIconOn { get { return Return(_visibilityIconOn, Dummy); } } - internal Texture VisibilityIconOff { get { return Return(_visibilityIconOff, Dummy); } } - internal Texture LabelIconType { get { return Return(_labelIconType, Dummy); } } - internal Texture LabelIconMeta { get { return Return(_labelIconMeta, Dummy); } } + 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; } } #endif } } \ No newline at end of file diff --git a/src/Internal/Icons/Resources/Icons.asset b/src/Internal/Icons/Resources/Icons.asset index 8aa1bf7..9962abd 100644 --- a/src/Internal/Icons/Resources/Icons.asset +++ b/src/Internal/Icons/Resources/Icons.asset @@ -15,17 +15,17 @@ MonoBehaviour: _helpIcon: {fileID: 0} _fileIcon: {fileID: 0} _metaIDIcon: {fileID: 0} - _repaireIcon: {fileID: 0} - _errorIcon: {fileID: 0} - _warningIcon:{fileID: 0} - _passIcon: {fileID: 0} - _unlinkIcon:{fileID: 0} - _searchIcon: {fileID: 0} - _closeIcon: {fileID: 0} - _closeIconOn: {fileID: 0} - _auotsetIcon: {fileID: 0} - _auotsetCascadeIcon: {fileID: 0} - _visibilityIconOn: {fileID: 0} - _visibilityIconOff: {fileID: 0} - _labelIconType: {fileID: 0} - _labelIconMeta: {fileID: 0} + _repaireIcon: {fileID: 0} + _errorIcon: {fileID: 0} + _warningIcon: {fileID: 0} + _passIcon: {fileID: 0} + _unlinkIcon: {fileID: 0} + _searchIcon: {fileID: 0} + _closeIcon: {fileID: 0} + _closeIconOn: {fileID: 0} + _auotsetIcon: {fileID: 0} + _auotsetCascadeIcon: {fileID: 0} + _visibilityIconOn: {fileID: 0} + _visibilityIconOff: {fileID: 0} + _labelIconType: {fileID: 0} + _labelIconMeta: {fileID: 0}