This commit is contained in:
Mikhail 2024-05-16 20:31:06 +08:00
parent 90cda16424
commit 2dd92d3dc6
4 changed files with 20 additions and 29 deletions

View File

@ -15,7 +15,7 @@ namespace DCFApixels.DragonECS
} }
[Serializable] [Serializable]
[MetaColor(255 / 3, 255, 0)] [MetaColor(255 / 3, 255, 0)]
[MetaDescription("Component-reference to Unity object for EcsPool")] [MetaDescription(EcsConsts.AUTHOR, "Component-reference to Unity object for EcsPool")]
[MetaGroup(UnityComponentConsts.UNITY_COMPONENT_NAME)] [MetaGroup(UnityComponentConsts.UNITY_COMPONENT_NAME)]
public struct UnityComponent<T> : IEcsComponent, IEnumerable<T>//IntelliSense hack public struct UnityComponent<T> : IEcsComponent, IEnumerable<T>//IntelliSense hack
where T : Component where T : Component

View File

@ -7,7 +7,7 @@ namespace DCFApixels.DragonECS
[Serializable] [Serializable]
public struct ComponentTemplateProperty : IEquatable<ComponentTemplateProperty> public struct ComponentTemplateProperty : IEquatable<ComponentTemplateProperty>
{ {
[SerializeReference, ComponentTemplateReference] [SerializeReference]
private IComponentTemplate _template; private IComponentTemplate _template;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public ComponentTemplateProperty(IComponentTemplate template) public ComponentTemplateProperty(IComponentTemplate template)
@ -41,23 +41,22 @@ namespace DCFApixels.DragonECS
public void OnValidate(UnityEngine.Object obj) { _template.OnValidate(obj); } public void OnValidate(UnityEngine.Object obj) { _template.OnValidate(obj); }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetRaw(object raw) { _template.SetRaw(raw); } public void SetRaw(object raw) { _template.SetRaw(raw); }
public bool Equals(ComponentTemplateProperty other) [MethodImpl(MethodImplOptions.AggressiveInlining)]
{ public bool Equals(ComponentTemplateProperty other) { return _template == other._template; }
return _template == other._template; [MethodImpl(MethodImplOptions.AggressiveInlining)]
} public override int GetHashCode() { return _template.GetHashCode(); }
public override bool Equals(object obj) public override bool Equals(object obj) { return obj is ComponentTemplateProperty other && Equals(other); }
{ [MethodImpl(MethodImplOptions.AggressiveInlining)]
return obj is ComponentTemplateProperty other && Equals(other);
}
public override int GetHashCode()
{
return _template.GetHashCode();
}
public static bool operator ==(ComponentTemplateProperty a, ComponentTemplateProperty b) { return a._template == b._template; } public static bool operator ==(ComponentTemplateProperty a, ComponentTemplateProperty b) { return a._template == b._template; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(ComponentTemplateProperty a, ComponentTemplateProperty b) { return a._template != b._template; } public static bool operator !=(ComponentTemplateProperty a, ComponentTemplateProperty b) { return a._template != b._template; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(ComponentTemplateProperty a, Null? b) { return a.IsNull; } public static bool operator ==(ComponentTemplateProperty a, Null? b) { return a.IsNull; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator ==(Null? a, ComponentTemplateProperty b) { return b.IsNull; } public static bool operator ==(Null? a, ComponentTemplateProperty b) { return b.IsNull; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(ComponentTemplateProperty a, Null? b) { return !a.IsNull; } public static bool operator !=(ComponentTemplateProperty a, Null? b) { return !a.IsNull; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool operator !=(Null? a, ComponentTemplateProperty b) { return !b.IsNull; } public static bool operator !=(Null? a, ComponentTemplateProperty b) { return !b.IsNull; }
public readonly struct Null { } public readonly struct Null { }
} }

View File

@ -33,9 +33,7 @@ namespace DCFApixels.DragonECS
{ {
#region Properties #region Properties
public abstract Type Type { get; } public abstract Type Type { get; }
public virtual bool IsCustomName { get { return false; } }
public virtual string Name { get { return string.Empty; } } public virtual string Name { get { return string.Empty; } }
public virtual bool IsCustomColor { get { return false; } }
public virtual MetaColor Color { get { return new MetaColor(MetaColor.Black); } } public virtual MetaColor Color { get { return new MetaColor(MetaColor.Black); } }
public virtual MetaGroup Group { get { return MetaGroup.Empty; } } public virtual MetaGroup Group { get { return MetaGroup.Empty; } }
public virtual MetaDescription Description { get { return MetaDescription.Empty; } } public virtual MetaDescription Description { get { return MetaDescription.Empty; } }
@ -59,10 +57,8 @@ namespace DCFApixels.DragonECS
protected T component; protected T component;
#region Properties #region Properties
public override Type Type { get { return typeof(T); } } public sealed override Type Type { get { return typeof(T); } }
public override bool IsCustomName { get { return Meta.IsCustomName; } }
public override string Name { get { return Meta.Name; } } public override string Name { get { return Meta.Name; } }
public override bool IsCustomColor { get { return Meta.IsCustomColor; } }
public override MetaColor Color { get { return Meta.Color; } } public override MetaColor Color { get { return Meta.Color; } }
public override MetaGroup Group { get { return Meta.Group; } } public override MetaGroup Group { get { return Meta.Group; } }
public override MetaDescription Description { get { return Meta.Description; } } public override MetaDescription Description { get { return Meta.Description; } }

View File

@ -294,29 +294,25 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
public static Color SelectPanelColor(ITypeMeta meta, int index, int total) public static Color SelectPanelColor(ITypeMeta meta, int index, int total)
{ {
Color panelColor; var trueMeta = meta.Type.ToMeta();
if (meta.IsCustomColor) if (trueMeta.IsCustomColor || meta.Color != trueMeta.Color)
{ {
panelColor = meta.Color.ToUnityColor(); return meta.Color.ToUnityColor();
} }
else else
{ {
switch (AutoColorMode) switch (AutoColorMode)
{ {
case ComponentColorMode.Auto: case ComponentColorMode.Auto:
panelColor = meta.Color.ToUnityColor().Desaturate(0.48f) / 1.18f; //.Desaturate(0.48f) / 1.18f; return meta.Color.ToUnityColor().Desaturate(0.48f) / 1.18f; //.Desaturate(0.48f) / 1.18f;
break;
case ComponentColorMode.Rainbow: case ComponentColorMode.Rainbow:
int localTotal = Mathf.Max(total, EscEditorConsts.AUTO_COLOR_RAINBOW_MIN_RANGE); int localTotal = Mathf.Max(total, EscEditorConsts.AUTO_COLOR_RAINBOW_MIN_RANGE);
Color hsv = Color.HSVToRGB(1f / localTotal * (index % localTotal), 1, 1); Color hsv = Color.HSVToRGB(1f / localTotal * (index % localTotal), 1, 1);
panelColor = hsv.Desaturate(0.48f) / 1.18f; return hsv.Desaturate(0.48f) / 1.18f;
break;
default: default:
panelColor = index % 2 == 0 ? new Color(0.40f, 0.40f, 0.40f) : new Color(0.54f, 0.54f, 0.54f); return index % 2 == 0 ? new Color(0.40f, 0.40f, 0.40f) : new Color(0.54f, 0.54f, 0.54f);
break;
} }
} }
return panelColor;
} }
public static bool AddComponentButtons(Rect position) public static bool AddComponentButtons(Rect position)
{ {