mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
Update style
This commit is contained in:
parent
0ccedb80a1
commit
51df885c61
8
src/Debug/Editor.meta
Normal file
8
src/Debug/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac4f146726b3ca444978fd7af0f5f883
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
34
src/Debug/Editor/EcsEditor.cs
Normal file
34
src/Debug/Editor/EcsEditor.cs
Normal file
@ -0,0 +1,34 @@
|
||||
#if UNITY_EDITOR
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
public static class EcsEditor
|
||||
{
|
||||
public static GUIStyle GetStyle(Color color)
|
||||
{
|
||||
GUIStyle style = new GUIStyle(GUI.skin.box);
|
||||
Color componentColor = color;
|
||||
componentColor.a = 0.15f;
|
||||
style.normal.background = CreateTexture(2, 2, componentColor);
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
private static Texture2D CreateTexture(int width, int height, Color color)
|
||||
{
|
||||
var pixels = new Color[width * height];
|
||||
for (var i = 0; i < pixels.Length; ++i)
|
||||
pixels[i] = color;
|
||||
|
||||
var result = new Texture2D(width, height);
|
||||
result.SetPixels(pixels);
|
||||
result.Apply();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
src/Debug/Editor/EcsEditor.cs.meta
Normal file
11
src/Debug/Editor/EcsEditor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f72bc8ca8108c2b4aac41df126dba1e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -86,10 +86,10 @@ namespace DCFApixels.DragonECS.Unity
|
||||
string name = type.Name;
|
||||
Color color = (GetAttribute<DebugColorAttribute>(type) ?? _fakeDebugColorAttribute).GetUnityColor();
|
||||
|
||||
Color defaultBackgroundColor = GUI.backgroundColor;
|
||||
//Color defaultBackgroundColor = GUI.backgroundColor;
|
||||
|
||||
GUI.backgroundColor = color;
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
//GUI.backgroundColor = color;
|
||||
GUILayout.BeginVertical(EcsEditor.GetStyle(color));
|
||||
if (Target.showInterfaces)
|
||||
{
|
||||
GUILayout.Label(string.Join(", ", type.GetInterfaces().Select(o => o.Name)), _interfacesStyle);
|
||||
@ -97,20 +97,21 @@ namespace DCFApixels.DragonECS.Unity
|
||||
GUILayout.Label(name, EditorStyles.boldLabel);
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUI.backgroundColor = defaultBackgroundColor;
|
||||
//GUI.backgroundColor = defaultBackgroundColor;
|
||||
}
|
||||
|
||||
private void DrawRunner(IEcsRunner runner)
|
||||
{
|
||||
Type type = runner.GetType();
|
||||
Color color = (GetAttribute<DebugColorAttribute>(type) ?? _fakeDebugColorAttribute).GetUnityColor();
|
||||
Color defaultBackgroundColor = GUI.backgroundColor;
|
||||
GUI.backgroundColor = color;
|
||||
GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
//Color defaultBackgroundColor = GUI.backgroundColor;
|
||||
//GUI.backgroundColor = color;
|
||||
GUILayout.BeginVertical(EcsEditor.GetStyle(color));
|
||||
//GUILayout.BeginVertical(EditorStyles.helpBox);
|
||||
GUILayout.Label(type.Name, EditorStyles.boldLabel);
|
||||
GUILayout.Label(string.Join(", ", runner.Targets.Cast<object>().Select(o => o.GetType().Name)));
|
||||
GUILayout.EndVertical();
|
||||
GUI.backgroundColor = defaultBackgroundColor;
|
||||
//GUI.backgroundColor = defaultBackgroundColor;
|
||||
}
|
||||
|
||||
private TAttribute GetAttribute<TAttribute>(Type target) where TAttribute : Attribute
|
||||
|
@ -6,7 +6,11 @@ namespace DCFApixels.DragonECS.Unity
|
||||
{
|
||||
public static Color GetUnityColor(this DebugColorAttribute self)
|
||||
{
|
||||
return new Color(self.r / 255f, self.g / 255f, self.b / 255f);
|
||||
return new Color(self.rn, self.gn, self.bn);
|
||||
}
|
||||
public static Color32 GetUnityColor32(this DebugColorAttribute self)
|
||||
{
|
||||
return new Color32(self.r, self.g, self.b, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user