Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
SerializableColor.cs
Go to the documentation of this file.
1using System;
2using Newtonsoft.Json;
3using UnityEngine;
4
5[Serializable]
6[JsonObject(MemberSerialization.OptIn)]
7public class SerializableColor
8{
9 [JsonProperty]
10 public byte[] _color;
11
12 public Color Get()
13 {
14 return (_color != null) ? new Color32(_color[0], _color[1], _color[2], _color[3]) : default(Color32);
15 }
16
18 {
19 }
20
22 {
23 Set(color);
24 }
25
26 public SerializableColor(byte[] bytes)
27 {
28 _color = bytes;
29 }
30
31 public SerializableColor(byte r, byte g, byte b, byte a = byte.MaxValue)
32 {
33 _color = new byte[4] { r, g, b, a };
34 }
35
37 {
38 Color32 color2 = color;
39 _color = new byte[4] { color2.r, color2.g, color2.b, color2.a };
40 return this;
41 }
42
43 public static void ToBytes(Color color, ref byte[] bytes, int index)
44 {
45 Color32 color2 = color;
46 new byte[4] { color2.r, color2.g, color2.b, color2.a }.CopyTo(bytes, index);
47 }
48
49 public static Color FromBytes(byte[] _color, int index)
50 {
51 return new Color32(_color[index], _color[index + 1], _color[index + 2], _color[index + 3]);
52 }
53}
SerializableColor(byte r, byte g, byte b, byte a=byte.MaxValue)
SerializableColor Set(Color color)
SerializableColor(Color color)
SerializableColor(byte[] bytes)
static void ToBytes(Color color, ref byte[] bytes, int index)
static Color FromBytes(byte[] _color, int index)