This commit is contained in:
Mikhail 2023-06-30 01:13:49 +08:00
parent 2a4978c907
commit bb73fbcdfe
5 changed files with 13 additions and 13 deletions

View File

@ -134,7 +134,7 @@ namespace DCFApixels.DragonECS
string name = EcsEditor.GetGenericName(type);
//Color color = (GetAttribute<DebugColorAttribute>(type) ?? _fakeDebugColorAttribute).GetUnityColor();
Color color = EcsDebugUtility.GetColorRGB(type).ToUnityColor();
Color color = EcsDebugUtility.GetColor(type).ToUnityColor();
GUILayout.BeginVertical(EcsEditor.GetStyle(color, 0.2f));
if (DebugMonitorPrefs.instance.IsShowInterfaces)
@ -152,7 +152,7 @@ namespace DCFApixels.DragonECS
return;
//Color color = (GetAttribute<DebugColorAttribute>(type) ?? _fakeDebugColorAttribute).GetUnityColor();
Color color = EcsDebugUtility.GetColorRGB(type).ToUnityColor();
Color color = EcsDebugUtility.GetColor(type).ToUnityColor();
GUILayout.BeginVertical(EcsEditor.GetStyle(color, 0.2f));
GUILayout.Label(EcsEditor.GetGenericName(type), EditorStyles.boldLabel);

View File

@ -170,7 +170,7 @@ namespace DCFApixels.DragonECS
string name = browsableName == null ? type.Name : GetLastPathComponent(browsableName.Name);
string description = customInitializer != null ? customInitializer.Description : initializerType.GetCustomAttribute<DebugDescriptionAttribute>()?.description;
// Color panelColor = customInitializer != null ? customInitializer.Color : initializerType.GetCustomAttribute<DebugColorAttribute>()?.GetUnityColor() ?? Color.black;
Color panelColor = customInitializer != null ? customInitializer.Color : EcsDebugUtility.GetColorRGB(initializerType).ToUnityColor();
Color panelColor = customInitializer != null ? customInitializer.Color : EcsDebugUtility.GetColor(initializerType).ToUnityColor();
GUILayout.BeginHorizontal();

View File

@ -44,7 +44,7 @@ namespace DCFApixels.DragonECS
//var atr = type.GetCustomAttribute<DebugColorAttribute>();
//if (atr == null) return Color.black;
//return atr.GetUnityColor();
return EcsDebugUtility.GetColorRGB(type).ToUnityColor();
return EcsDebugUtility.GetColor(type).ToUnityColor();
}
internal static string GetName(Type type)
{

View File

@ -7,10 +7,10 @@ namespace DCFApixels.DragonECS
{
[Serializable]
[DebugColor(255 / 3, 255, 0)]
public readonly struct UnityComponent<T> : IEcsComponent, IEnumerable<T>//IntelliSense hack
public struct UnityComponent<T> : IEcsComponent, IEnumerable<T>//IntelliSense hack
where T : Component
{
public readonly T obj;
public T obj;
public UnityComponent(T obj) => this.obj = obj;
IEnumerator<T> IEnumerable<T>.GetEnumerator() => throw new NotImplementedException(); //IntelliSense hack
IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException(); //IntelliSense hack
@ -24,7 +24,7 @@ namespace DCFApixels.DragonECS
public override void OnValidate(GameObject gameObject)
{
if (component.obj == null)
component = new UnityComponent<T>(gameObject.GetComponent<T>());
component.obj = gameObject.GetComponent<T>();
}
}

View File

@ -6,20 +6,20 @@ namespace DCFApixels.DragonECS
{
public static Color GetUnityColor(this DebugColorAttribute self)
{
return new Color(self.r / 255f, self.g / 255f, self.b / 255f);
return self.color.ToUnityColor();
}
public static Color32 GetUnityColor32(this DebugColorAttribute self)
{
return new Color32(self.r, self.g, self.b, 255);
return self.color.ToUnityColor32();
}
public static Color ToUnityColor(this (byte, byte, byte) self)
public static Color ToUnityColor(this DebugColor self)
{
return new Color(self.Item1 / 255f, self.Item2 / 255f, self.Item3 / 255f);
return new Color(self.r / 255f, self.g / 255f, self.b / 255f, self.a / 255f);
}
public static Color32 ToUnityColor32(this (byte, byte, byte) self)
public static Color32 ToUnityColor32(this DebugColor self)
{
return new Color32(self.Item1, self.Item2, self.Item3, 255);
return new Color32(self.r, self.g, self.b, self.a);
}
}
}