diff --git a/EXILED/Exiled.Loader/Features/Configs/CustomConverters/ColorConverter.cs b/EXILED/Exiled.Loader/Features/Configs/CustomConverters/ColorConverter.cs index fb29d8293..a29574ca8 100644 --- a/EXILED/Exiled.Loader/Features/Configs/CustomConverters/ColorConverter.cs +++ b/EXILED/Exiled.Loader/Features/Configs/CustomConverters/ColorConverter.cs @@ -30,7 +30,7 @@ public sealed class ColorConverter : IYamlTypeConverter public bool Accepts(Type type) { Type baseType = Nullable.GetUnderlyingType(type) ?? type; - return baseType == typeof(Color); + return baseType == typeof(Color) || baseType == typeof(Color32); } /// @@ -57,6 +57,8 @@ public object ReadYaml(IParser parser, Type type) List coordinates = ListPool.Pool.Get(4); int i = 0; + bool isColor32 = baseType == typeof(Color32); + while (!parser.TryConsume(out _)) { if (i++ % 2 == 0) @@ -71,6 +73,11 @@ public object ReadYaml(IParser parser, Type type) throw new InvalidDataException("Invalid float value."); } + if (isColor32) + { + coordinates.Add((byte)Mathf.Round(Mathf.Clamp01(coordinate) * 255f)); + } + coordinates.Add(coordinate); } @@ -99,6 +106,14 @@ public void WriteYaml(IEmitter emitter, object value, Type type) coordinates["b"] = color.b; coordinates["a"] = color.a; } + else if (value is Color32 color32) + { + color = color32; + coordinates["r"] = color.r; + coordinates["g"] = color.g; + coordinates["b"] = color.b; + coordinates["a"] = color.a; + } emitter.Emit(new MappingStart());