mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
fix icons display
This commit is contained in:
parent
363856226d
commit
f31eb5fe56
@ -3,37 +3,27 @@ using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
public class Icons : ScriptableObject
|
||||
public class Icons : Config<Icons>
|
||||
{
|
||||
private static object _lock = new object();
|
||||
private static Icons _instance;
|
||||
public static Icons Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = CreateInstance<Icons>();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
[SerializeField]
|
||||
private Texture _helpIcon;
|
||||
[SerializeField]
|
||||
private Texture _closeIcon;
|
||||
[SerializeField]
|
||||
private Texture _closeIconOn;
|
||||
[SerializeField]
|
||||
private Texture _unlinkIcon;
|
||||
[SerializeField]
|
||||
private Texture _auotsetIcon;
|
||||
[SerializeField]
|
||||
private Texture _auotsetCascadeIcon;
|
||||
|
||||
[SerializeField]
|
||||
internal Texture _helpIcon;
|
||||
[SerializeField]
|
||||
internal Texture _closeIcon;
|
||||
[SerializeField]
|
||||
internal Texture _closeIconOn;
|
||||
[SerializeField]
|
||||
internal Texture _unlinkIcon;
|
||||
[SerializeField]
|
||||
internal Texture _auotsetIcon;
|
||||
[SerializeField]
|
||||
internal Texture _auotsetCascadeIcon;
|
||||
internal Texture HelpIcon { get { return _helpIcon; } }
|
||||
internal Texture CloseIcon { get { return _closeIcon; } }
|
||||
internal Texture CloseIconOn { get { return _closeIconOn; } }
|
||||
internal Texture UnlinkIcon { get { return _unlinkIcon; } }
|
||||
internal Texture AuotsetIcon { get { return _auotsetIcon; } }
|
||||
internal Texture AutosetCascadeIcon { get { return _auotsetCascadeIcon; } }
|
||||
}
|
||||
}
|
||||
#endif
|
40
src/Internal/Config.cs
Normal file
40
src/Internal/Config.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels
|
||||
{
|
||||
public abstract class Config<TSelf> : ScriptableObject where TSelf : ScriptableObject
|
||||
{
|
||||
private static object _lock = new object();
|
||||
private static TSelf _instance;
|
||||
public static TSelf Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
string path = typeof(TSelf).ToString();
|
||||
_instance = Resources.Load<TSelf>(typeof(TSelf).Name);
|
||||
if (_instance == null)
|
||||
{
|
||||
TSelf data = CreateInstance<TSelf>();
|
||||
#if UNITY_EDITOR
|
||||
if (AssetDatabase.IsValidFolder("Assets/Resources/") == false)
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(Application.dataPath + "/Resources/");
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
AssetDatabase.CreateAsset(data, "Assets/Resources/" + typeof(TSelf).Name + ".asset");
|
||||
AssetDatabase.Refresh();
|
||||
#endif
|
||||
_instance = data;
|
||||
}
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
src/Internal/Config.cs.meta
Normal file
11
src/Internal/Config.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b06d073449be7a41b1113cc0282f1fe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -114,7 +114,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
using (new ColorScope(new Color(1f, 1f, 1f, 0.8f)))
|
||||
{
|
||||
DrawIcon(position, Icons.Instance._helpIcon, 0, description);
|
||||
DrawIcon(position, Icons.Instance.HelpIcon, 0, description);
|
||||
}
|
||||
}
|
||||
public static bool CloseButton(Rect position)
|
||||
@ -124,30 +124,30 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
var (hover, click) = IconButtonGeneric(position);
|
||||
if (hover)
|
||||
{
|
||||
DrawIcon(position, Icons.Instance._closeIconOn, -4f, null);
|
||||
DrawIcon(position, Icons.Instance.CloseIconOn, -4f, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawIcon(position, Icons.Instance._closeIcon, 0, null);
|
||||
DrawIcon(position, Icons.Instance.CloseIcon, 0, null);
|
||||
}
|
||||
return click;
|
||||
}
|
||||
}
|
||||
public static bool AutosetCascadeButton(Rect position)
|
||||
{
|
||||
return IconButton(position, Icons.Instance._auotsetCascadeIcon, 0f, "Autoset Cascade");
|
||||
return IconButton(position, Icons.Instance.AutosetCascadeIcon, 0f, "Autoset Cascade");
|
||||
}
|
||||
public static bool AutosetButton(Rect position)
|
||||
{
|
||||
return IconButton(position, Icons.Instance._auotsetIcon, 1f, "Autoset");
|
||||
return IconButton(position, Icons.Instance.AuotsetIcon, 1f, "Autoset");
|
||||
}
|
||||
public static bool UnlinkButton(Rect position)
|
||||
{
|
||||
return IconButton(position, Icons.Instance._unlinkIcon, 1f, "Unlink Entity");
|
||||
return IconButton(position, Icons.Instance.UnlinkIcon, 1f, "Unlink Entity");
|
||||
}
|
||||
public static bool DelEntityButton(Rect position)
|
||||
{
|
||||
return IconButton(position, Icons.Instance._closeIcon, 0f, "Delete Entity");
|
||||
return IconButton(position, Icons.Instance.CloseIcon, 0f, "Delete Entity");
|
||||
}
|
||||
public static void EntityBar(Rect position, EntityStatus status, int id, short gen, short world)
|
||||
{
|
||||
|
8
src/Resources.meta
Normal file
8
src/Resources.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e5cbb3e099a19c438a1fdfd46179abc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
src/Resources/Icons.asset
Normal file
20
src/Resources/Icons.asset
Normal file
@ -0,0 +1,20 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2ce72fefbf3696f4fb3861773bd997df, type: 3}
|
||||
m_Name: Icons
|
||||
m_EditorClassIdentifier:
|
||||
_helpIcon: {fileID: 2800000, guid: e135cf23a5d53ce48a75e163b41e39d5, type: 3}
|
||||
_closeIcon: {fileID: 2800000, guid: 8a708e50662813d4a99c107e6431a60b, type: 3}
|
||||
_closeIconOn: {fileID: 2800000, guid: 6a1d402595b00c24db2ba647fed93a5c, type: 3}
|
||||
_unlinkIcon: {fileID: 2800000, guid: 5baead89a941e034e9f44d63617d3246, type: 3}
|
||||
_auotsetIcon: {fileID: 2800000, guid: d01e651682f48b548b597714f47e14b9, type: 3}
|
||||
_auotsetCascadeIcon: {fileID: 2800000, guid: 8f9fb2a8877577940971d81a98aeaaaa, type: 3}
|
8
src/Resources/Icons.asset.meta
Normal file
8
src/Resources/Icons.asset.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8cd327a6b50b9df45afb5fa60f143b03
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user