diff --git a/spine-csharp/src/Animation.cs b/spine-csharp/src/Animation.cs
index 466c7621e..9f9dde613 100644
--- a/spine-csharp/src/Animation.cs
+++ b/spine-csharp/src/Animation.cs
@@ -36,7 +36,7 @@ using System.Collections.Generic;
namespace Spine {
#if IS_UNITY
- using Color = UnityEngine.Color;
+ using Color32F = UnityEngine.Color;
#endif
///
@@ -1055,16 +1055,16 @@ namespace Spine {
override protected void Apply (Slot slot, SlotPose pose, float time, float alpha, MixBlend blend) {
float[] frames = this.frames;
- Color color = pose.GetColor();
+ Color32F color = pose.GetColor();
if (time < frames[0]) {
- Color setup = slot.data.setup.GetColor();
+ Color32F setup = slot.data.setup.GetColor();
switch (blend) {
case MixBlend.Setup:
color = setup;
pose.SetColor(color); // required due to Color being a struct
return;
case MixBlend.First:
- color += new Color((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha,
+ color += new Color32F((setup.r - color.r) * alpha, (setup.g - color.g) * alpha, (setup.b - color.b) * alpha,
(setup.a - color.a) * alpha);
color.Clamp();
pose.SetColor(color); // see above
@@ -1103,10 +1103,10 @@ namespace Spine {
}
if (alpha == 1) {
- color = new Color(r, g, b, a);
+ color = new Color32F(r, g, b, a);
} else {
if (blend == MixBlend.Setup) color = slot.data.setup.GetColor();
- color += new Color((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
+ color += new Color32F((r - color.r) * alpha, (g - color.g) * alpha, (b - color.b) * alpha, (a - color.a) * alpha);
}
color.Clamp();
pose.SetColor(color); // see above
@@ -1140,9 +1140,9 @@ namespace Spine {
override protected void Apply (Slot slot, SlotPose pose, float time, float alpha, MixBlend blend) {
float[] frames = this.frames;
- Color color = pose.GetColor();
+ Color32F color = pose.GetColor();
if (time < frames[0]) {
- Color setup = slot.data.setup.GetColor();
+ Color32F setup = slot.data.setup.GetColor();
switch (blend) {
case MixBlend.Setup:
color.r = setup.r;
@@ -1194,7 +1194,7 @@ namespace Spine {
pose.SetColor(color); // see above
} else {
if (blend == MixBlend.Setup) {
- Color setup = slot.data.setup.GetColor();
+ Color32F setup = slot.data.setup.GetColor();
color.r = setup.r;
color.g = setup.g;
color.b = setup.b;
@@ -1230,11 +1230,11 @@ namespace Spine {
if (!slot.bone.active) return;
SlotPose pose = (appliedPose ? slot.applied : slot.pose);
- Color color = pose.GetColor();
+ Color32F color = pose.GetColor();
float[] frames = this.frames;
if (time < frames[0]) {
- Color setup = slot.data.setup.GetColor();
+ Color32F setup = slot.data.setup.GetColor();
switch (blend) {
case MixBlend.Setup:
color.a = setup.a;
@@ -1296,24 +1296,24 @@ namespace Spine {
override protected void Apply (Slot slot, SlotPose pose, float time, float alpha, MixBlend blend) {
float[] frames = this.frames;
- Color light = pose.GetColor();
- Color? dark = pose.GetDarkColor();
+ Color32F light = pose.GetColor();
+ Color32F? dark = pose.GetDarkColor();
if (time < frames[0]) {
SlotPose setup = slot.data.setup;
- Color setupLight = setup.GetColor();
- Color? setupDark = setup.GetDarkColor();
+ Color32F setupLight = setup.GetColor();
+ Color32F? setupDark = setup.GetDarkColor();
switch (blend) {
case MixBlend.Setup:
pose.SetColor(setupLight); // required due to Color being a struct
pose.SetDarkColor(setupDark);
return;
case MixBlend.First:
- light += new Color((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha,
+ light += new Color32F((setupLight.r - light.r) * alpha, (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha,
(setupLight.a - light.a) * alpha);
light.Clamp();
- Color darkValue = dark.Value;
- Color setupDarkValue = setupDark.Value;
+ Color32F darkValue = dark.Value;
+ Color32F setupDarkValue = setupDark.Value;
darkValue.r += (setupDarkValue.r - darkValue.r) * alpha;
darkValue.g += (setupDarkValue.g - darkValue.g) * alpha;
darkValue.b += (setupDarkValue.b - darkValue.b) * alpha;
@@ -1368,10 +1368,10 @@ namespace Spine {
}
if (alpha == 1) {
- light = new Color(r, g, b, a);
+ light = new Color32F(r, g, b, a);
light.Clamp();
- Color darkValue = dark.Value;
+ Color32F darkValue = dark.Value;
darkValue.r = r2;
darkValue.g = g2;
darkValue.b = b2;
@@ -1380,17 +1380,17 @@ namespace Spine {
pose.SetColor(light); // required due to Color being a struct
pose.SetDarkColor(darkValue);
} else {
- Color darkValue = dark.Value;
+ Color32F darkValue = dark.Value;
if (blend == MixBlend.Setup) {
SlotPose setup = slot.data.setup;
light = setup.GetColor();
- Color? setupDark = setup.GetDarkColor();
- Color setupDarkValue = setupDark.Value;
+ Color32F? setupDark = setup.GetDarkColor();
+ Color32F setupDarkValue = setupDark.Value;
darkValue.r = setupDarkValue.r;
darkValue.g = setupDarkValue.g;
darkValue.b = setupDarkValue.b;
}
- light += new Color((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha);
+ light += new Color32F((r - light.r) * alpha, (g - light.g) * alpha, (b - light.b) * alpha, (a - light.a) * alpha);
light.Clamp();
darkValue.r += (r2 - darkValue.r) * alpha;
@@ -1437,14 +1437,14 @@ namespace Spine {
override protected void Apply (Slot slot, SlotPose pose, float time, float alpha, MixBlend blend) {
float[] frames = this.frames;
- Color light = pose.GetColor();
- Color? dark = pose.GetDarkColor();
+ Color32F light = pose.GetColor();
+ Color32F? dark = pose.GetDarkColor();
if (time < frames[0]) {
SlotPose setup = slot.data.setup;
- Color setupLight = setup.GetColor();
- Color? setupDark = setup.GetDarkColor();
- Color darkValue = dark.Value;
- Color setupDarkValue = setupDark.Value;
+ Color32F setupLight = setup.GetColor();
+ Color32F? setupDark = setup.GetDarkColor();
+ Color32F darkValue = dark.Value;
+ Color32F setupDarkValue = setupDark.Value;
switch (blend) {
case MixBlend.Setup:
@@ -1520,7 +1520,7 @@ namespace Spine {
light.b = b;
light.Clamp();
- Color darkValue = dark.Value;
+ Color32F darkValue = dark.Value;
darkValue.r = r2;
darkValue.g = g2;
darkValue.b = b2;
@@ -1529,13 +1529,13 @@ namespace Spine {
pose.SetColor(light); // required due to Color being a struct
pose.SetDarkColor(darkValue);
} else {
- Color darkValue = dark.Value;
+ Color32F darkValue = dark.Value;
if (blend == MixBlend.Setup) {
SlotPose setup = slot.data.setup;
- Color setupLight = setup.GetColor();
- Color? setupDark = setup.GetDarkColor();
- Color setupDarkValue = setupDark.Value;
+ Color32F setupLight = setup.GetColor();
+ Color32F? setupDark = setup.GetDarkColor();
+ Color32F setupDarkValue = setupDark.Value;
light.r = setupLight.r;
light.g = setupLight.g;
diff --git a/spine-csharp/src/Attachments/IHasTextureRegion.cs b/spine-csharp/src/Attachments/IHasTextureRegion.cs
index 6186737ed..b17221ef1 100644
--- a/spine-csharp/src/Attachments/IHasTextureRegion.cs
+++ b/spine-csharp/src/Attachments/IHasTextureRegion.cs
@@ -33,7 +33,7 @@
namespace Spine {
#if IS_UNITY
- using Color = UnityEngine.Color;
+ using Color32F = UnityEngine.Color;
#endif
public interface IHasTextureRegion {
@@ -51,8 +51,8 @@ namespace Spine {
///
void UpdateRegion ();
- Color GetColor ();
- void SetColor (Color color);
+ Color32F GetColor ();
+ void SetColor (Color32F color);
void SetColor (float r, float g, float b, float a);
Sequence Sequence { get; set; }
diff --git a/spine-csharp/src/Attachments/MeshAttachment.cs b/spine-csharp/src/Attachments/MeshAttachment.cs
index 2dc5e74fa..6ae2e5415 100644
--- a/spine-csharp/src/Attachments/MeshAttachment.cs
+++ b/spine-csharp/src/Attachments/MeshAttachment.cs
@@ -35,7 +35,7 @@ using System;
namespace Spine {
#if IS_UNITY
- using Color = UnityEngine.Color;
+ using Color32F = UnityEngine.Color;
#endif
/// Attachment that displays a texture region using a mesh.
@@ -48,7 +48,7 @@ namespace Spine {
// Color color = slot.color; color.a = 0.5;
// modifying just a copy of the struct instead of the original
// object as in reference implementation.
- protected Color color = new Color(1, 1, 1, 1);
+ protected Color32F color = new Color32F(1, 1, 1, 1);
internal int hullLength;
private MeshAttachment parentMesh;
private Sequence sequence;
@@ -67,16 +67,16 @@ namespace Spine {
public float[] UVs { get { return uvs; } set { uvs = value; } }
public int[] Triangles { get { return triangles; } set { triangles = value; } }
- public Color GetColor () {
+ public Color32F GetColor () {
return color;
}
- public void SetColor (Color color) {
+ public void SetColor (Color32F color) {
this.color = color;
}
public void SetColor (float r, float g, float b, float a) {
- color = new Color(r, g, b, a);
+ color = new Color32F(r, g, b, a);
}
public string Path { get { return path; } set { path = value; } }
diff --git a/spine-csharp/src/Attachments/RegionAttachment.cs b/spine-csharp/src/Attachments/RegionAttachment.cs
index caba05296..125f992ab 100644
--- a/spine-csharp/src/Attachments/RegionAttachment.cs
+++ b/spine-csharp/src/Attachments/RegionAttachment.cs
@@ -35,7 +35,7 @@ using System;
namespace Spine {
#if IS_UNITY
- using Color = UnityEngine.Color;
+ using Color32F = UnityEngine.Color;
#endif
/// Attachment that displays a texture region.
@@ -52,7 +52,7 @@ namespace Spine {
// Color color = slot.color; color.a = 0.5;
// modifying just a copy of the struct instead of the original
// object as in reference implementation.
- protected Color color = new Color(1, 1, 1, 1);
+ protected Color32F color = new Color32F(1, 1, 1, 1);
internal Sequence sequence;
public float X { get { return x; } set { x = value; } }
@@ -63,16 +63,16 @@ namespace Spine {
public float Width { get { return width; } set { width = value; } }
public float Height { get { return height; } set { height = value; } }
- public Color GetColor () {
+ public Color32F GetColor () {
return color;
}
- public void SetColor (Color color) {
+ public void SetColor (Color32F color) {
this.color = color;
}
public void SetColor (float r, float g, float b, float a) {
- color = new Color(r, g, b, a);
+ color = new Color32F(r, g, b, a);
}
public string Path { get; set; }
diff --git a/spine-csharp/src/Color.cs.meta b/spine-csharp/src/Color.cs.meta
deleted file mode 100644
index 213549e4e..000000000
--- a/spine-csharp/src/Color.cs.meta
+++ /dev/null
@@ -1,2 +0,0 @@
-fileFormatVersion: 2
-guid: 445e5522c6d723a4bb98798781daa7d0
\ No newline at end of file
diff --git a/spine-csharp/src/ColorMono.cs b/spine-csharp/src/ColorMono.cs
new file mode 100644
index 000000000..fc59368e6
--- /dev/null
+++ b/spine-csharp/src/ColorMono.cs
@@ -0,0 +1,104 @@
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated April 5, 2025. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2025, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
+ * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#if UNITY_5_3_OR_NEWER
+#define IS_UNITY
+#endif
+
+#if !IS_UNITY
+namespace Spine {
+ ///
+ /// 32 bit floating point color to be used with XNA/Monogame.
+ ///
+ public struct Color32F {
+ public float r, g, b, a;
+
+ public Color32F (float r, float g, float b, float a = 1.0f) {
+ this.r = r;
+ this.g = g;
+ this.b = b;
+ this.a = a;
+ }
+
+ public Color32F (Microsoft.Xna.Framework.Color xnaColor)
+ : this(xnaColor.R / 255f, xnaColor.G / 255f, xnaColor.B / 255f, xnaColor.A / 255f) {
+ }
+
+ public static implicit operator Color32F (Microsoft.Xna.Framework.Color xnaColor) {
+ return new Color32F(xnaColor);
+ }
+
+ public static implicit operator Microsoft.Xna.Framework.Color (Color32F c) {
+ return new Microsoft.Xna.Framework.Color(
+ (byte)(c.r * 255),
+ (byte)(c.g * 255),
+ (byte)(c.b * 255),
+ (byte)(c.a * 255)
+ );
+ }
+
+ public override string ToString () {
+ return string.Format("RGBA({0}, {1}, {2}, {3})", r, g, b, a);
+ }
+
+ public static Color32F operator + (Color32F c1, Color32F c2) {
+ return new Color32F(c1.r + c2.r, c1.g + c2.g, c1.b + c2.b, c1.a + c2.a);
+ }
+
+ public static Color32F operator - (Color32F c1, Color32F c2) {
+ return new Color32F(c1.r - c2.r, c1.g - c2.g, c1.b - c2.b, c1.a - c2.a);
+ }
+ }
+
+ static class ColorExtensions {
+ public static Color32F Clamp (this Color32F color) {
+ color.r = MathUtils.Clamp(color.r, 0, 1);
+ color.g = MathUtils.Clamp(color.g, 0, 1);
+ color.b = MathUtils.Clamp(color.b, 0, 1);
+ color.a = MathUtils.Clamp(color.a, 0, 1);
+ return color;
+ }
+
+ public static Color32F RGBA8888ToColor (this uint rgba8888) {
+ float r = ((rgba8888 & 0xff000000) >> 24) / 255f;
+ float g = ((rgba8888 & 0x00ff0000) >> 16) / 255f;
+ float b = ((rgba8888 & 0x0000ff00) >> 8) / 255f;
+ float a = ((rgba8888 & 0x000000ff)) / 255f;
+ return new Color32F(r, g, b, a);
+ }
+
+ public static Color32F XRGB888ToColor (this uint xrgb888) {
+ float r = ((xrgb888 & 0x00ff0000) >> 16) / 255f;
+ float g = ((xrgb888 & 0x0000ff00) >> 8) / 255f;
+ float b = ((xrgb888 & 0x000000ff)) / 255f;
+ return new Color32F(r, g, b);
+ }
+ }
+}
+#endif
diff --git a/spine-csharp/src/ColorMono.cs.meta b/spine-csharp/src/ColorMono.cs.meta
new file mode 100644
index 000000000..048c785ca
--- /dev/null
+++ b/spine-csharp/src/ColorMono.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 3eb49ca43afc71d41bdadef9155891e0
\ No newline at end of file
diff --git a/spine-csharp/src/Color.cs b/spine-csharp/src/ColorOther.cs
similarity index 77%
rename from spine-csharp/src/Color.cs
rename to spine-csharp/src/ColorOther.cs
index 4796fe5dd..9989214e0 100644
--- a/spine-csharp/src/Color.cs
+++ b/spine-csharp/src/ColorOther.cs
@@ -31,14 +31,15 @@
#define IS_UNITY
#endif
+#if !IS_UNITY
namespace Spine {
-#if IS_UNITY
- using Color = UnityEngine.Color;
-#else
- public struct Color {
+ ///
+ /// 32 bit floating point color to be used with other game toolkits than Unity and XNA/Monogame.
+ ///
+ public struct Color32F {
public float r, g, b, a;
- public Color (float r, float g, float b, float a = 1.0f) {
+ public Color32F (float r, float g, float b, float a = 1.0f) {
this.r = r;
this.g = g;
this.b = b;
@@ -49,18 +50,17 @@ namespace Spine {
return string.Format("RGBA({0}, {1}, {2}, {3})", r, g, b, a);
}
- public static Color operator + (Color c1, Color c2) {
- return new Color(c1.r + c2.r, c1.g + c2.g, c1.b + c2.b, c1.a + c2.a);
+ public static Color32F operator + (Color32F c1, Color32F c2) {
+ return new Color32F(c1.r + c2.r, c1.g + c2.g, c1.b + c2.b, c1.a + c2.a);
}
- public static Color operator - (Color c1, Color c2) {
- return new Color(c1.r - c2.r, c1.g - c2.g, c1.b - c2.b, c1.a - c2.a);
+ public static Color32F operator - (Color32F c1, Color32F c2) {
+ return new Color32F(c1.r - c2.r, c1.g - c2.g, c1.b - c2.b, c1.a - c2.a);
}
}
-#endif
static class ColorExtensions {
- public static Color Clamp (this Color color) {
+ public static Color32F Clamp (this Color32F color) {
color.r = MathUtils.Clamp(color.r, 0, 1);
color.g = MathUtils.Clamp(color.g, 0, 1);
color.b = MathUtils.Clamp(color.b, 0, 1);
@@ -68,19 +68,20 @@ namespace Spine {
return color;
}
- public static Color RGBA8888ToColor(this uint rgba8888) {
+ public static Color32F RGBA8888ToColor (this uint rgba8888) {
float r = ((rgba8888 & 0xff000000) >> 24) / 255f;
float g = ((rgba8888 & 0x00ff0000) >> 16) / 255f;
float b = ((rgba8888 & 0x0000ff00) >> 8) / 255f;
float a = ((rgba8888 & 0x000000ff)) / 255f;
- return new Color(r, g, b, a);
+ return new Color32F(r, g, b, a);
}
- public static Color XRGB888ToColor (this uint xrgb888) {
+ public static Color32F XRGB888ToColor (this uint xrgb888) {
float r = ((xrgb888 & 0x00ff0000) >> 16) / 255f;
float g = ((xrgb888 & 0x0000ff00) >> 8) / 255f;
float b = ((xrgb888 & 0x000000ff)) / 255f;
- return new Color(r, g, b);
+ return new Color32F(r, g, b);
}
}
}
+#endif
diff --git a/spine-csharp/src/ColorOther.cs.meta b/spine-csharp/src/ColorOther.cs.meta
new file mode 100644
index 000000000..086d865c6
--- /dev/null
+++ b/spine-csharp/src/ColorOther.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: b6c7cc15ba45b0045a609f65b360220a
\ No newline at end of file
diff --git a/spine-csharp/src/ColorUnity.cs b/spine-csharp/src/ColorUnity.cs
new file mode 100644
index 000000000..5b80a65fc
--- /dev/null
+++ b/spine-csharp/src/ColorUnity.cs
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * Spine Runtimes License Agreement
+ * Last updated April 5, 2025. Replaces all prior versions.
+ *
+ * Copyright (c) 2013-2025, Esoteric Software LLC
+ *
+ * Integration of the Spine Runtimes into software or otherwise creating
+ * derivative works of the Spine Runtimes is permitted under the terms and
+ * conditions of Section 2 of the Spine Editor License Agreement:
+ * http://esotericsoftware.com/spine-editor-license
+ *
+ * Otherwise, it is permitted to integrate the Spine Runtimes into software
+ * or otherwise create derivative works of the Spine Runtimes (collectively,
+ * "Products"), provided that each user of the Products must obtain their own
+ * Spine Editor license and redistribution of the Products in any form must
+ * include this license and copyright notice.
+ *
+ * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
+ * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *****************************************************************************/
+
+#if UNITY_5_3_OR_NEWER
+#define IS_UNITY
+#endif
+
+#if IS_UNITY
+namespace Spine {
+ using Color32F = UnityEngine.Color;
+
+ static class ColorExtensions {
+ public static Color32F Clamp (this Color32F color) {
+ color.r = MathUtils.Clamp(color.r, 0, 1);
+ color.g = MathUtils.Clamp(color.g, 0, 1);
+ color.b = MathUtils.Clamp(color.b, 0, 1);
+ color.a = MathUtils.Clamp(color.a, 0, 1);
+ return color;
+ }
+
+ public static Color32F RGBA8888ToColor(this uint rgba8888) {
+ float r = ((rgba8888 & 0xff000000) >> 24) / 255f;
+ float g = ((rgba8888 & 0x00ff0000) >> 16) / 255f;
+ float b = ((rgba8888 & 0x0000ff00) >> 8) / 255f;
+ float a = ((rgba8888 & 0x000000ff)) / 255f;
+ return new Color32F(r, g, b, a);
+ }
+
+ public static Color32F XRGB888ToColor (this uint xrgb888) {
+ float r = ((xrgb888 & 0x00ff0000) >> 16) / 255f;
+ float g = ((xrgb888 & 0x0000ff00) >> 8) / 255f;
+ float b = ((xrgb888 & 0x000000ff)) / 255f;
+ return new Color32F(r, g, b);
+ }
+ }
+}
+#endif
diff --git a/spine-csharp/src/ColorUnity.cs.meta b/spine-csharp/src/ColorUnity.cs.meta
new file mode 100644
index 000000000..5ac6ad7d2
--- /dev/null
+++ b/spine-csharp/src/ColorUnity.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: c96d35d696c85a44ab68037d151dde5d
\ No newline at end of file
diff --git a/spine-csharp/src/Skeleton.cs b/spine-csharp/src/Skeleton.cs
index 988f4cdad..92127a23e 100644
--- a/spine-csharp/src/Skeleton.cs
+++ b/spine-csharp/src/Skeleton.cs
@@ -35,7 +35,7 @@ using System;
namespace Spine {
#if IS_UNITY
- using Color = UnityEngine.Color;
+ using Color32F = UnityEngine.Color;
#endif
public class Skeleton {
static private readonly int[] quadTriangles = { 0, 1, 2, 2, 3, 0 };
@@ -49,10 +49,10 @@ namespace Spine {
internal ExposedList resetCache = new ExposedList(16);
internal Skin skin;
// Color is a struct, set to protected to prevent
- // Color color = slot.color; color.a = 0.5;
+ // Color32F color = slot.color; color.a = 0.5;
// modifying just a copy of the struct instead of the original
// object as in reference implementation.
- protected Color color;
+ protected Color32F color;
internal float x, y, scaleX = 1, time, windX = 1, windY = 0, gravityX = 0, gravityY = 1;
/// Private to enforce usage of ScaleY getter taking Bone.yDown into account.
private float scaleY = 1;
@@ -95,7 +95,7 @@ namespace Spine {
}
physics.TrimExcess();
- color = new Color(1, 1, 1, 1);
+ color = new Color32F(1, 1, 1, 1);
UpdateCache();
}
@@ -505,21 +505,21 @@ namespace Spine {
}
/// A copy of the color to tint all the skeleton's attachments.
- public Color GetColor () {
+ public Color32F GetColor () {
return color;
}
/// Sets the color to tint all the skeleton's attachments.
- public void SetColor (Color color) {
+ public void SetColor (Color32F color) {
this.color = color;
}
///
/// A convenience method for setting the skeleton color. The color can also be set by
- ///
+ ///
///
public void SetColor (float r, float g, float b, float a) {
- color = new Color(r, g, b, a);
+ color = new Color32F(r, g, b, a);
}
/// Scales the entire skeleton on the X axis.
diff --git a/spine-csharp/src/SkeletonJson.cs b/spine-csharp/src/SkeletonJson.cs
index 6c0076d83..59c698e73 100644
--- a/spine-csharp/src/SkeletonJson.cs
+++ b/spine-csharp/src/SkeletonJson.cs
@@ -43,7 +43,7 @@ using Windows.Storage;
namespace Spine {
#if IS_UNITY
- using Color = UnityEngine.Color;
+ using Color32F = UnityEngine.Color;
#endif
using FromProperty = TransformConstraintData.FromProperty;
@@ -1558,7 +1558,7 @@ namespace Spine {
return Convert.ToInt32(hexString.Substring(colorIndex * 2, 2), 16) / (float)255;
}
- static Color ToColor32 (string hexString, int expectedLength = 8) {
+ static Color32F ToColor32 (string hexString, int expectedLength = 8) {
if (hexString.Length < expectedLength)
throw new ArgumentException("Color hexadecimal length must be " + expectedLength + ", received: " + hexString, "hexString");
@@ -1566,17 +1566,17 @@ namespace Spine {
float g = Convert.ToInt32(hexString.Substring(2, 2), 16) / (float)255;
float b = Convert.ToInt32(hexString.Substring(4, 2), 16) / (float)255;
float a = Convert.ToInt32(hexString.Substring(6, 2), 16) / (float)255;
- return new Color(r, g, b, a);
+ return new Color32F(r, g, b, a);
}
- static Color ToColor24 (string hexString, int expectedLength = 6) {
+ static Color32F ToColor24 (string hexString, int expectedLength = 6) {
if (hexString.Length < expectedLength)
throw new ArgumentException("Color hexadecimal length must be " + expectedLength + ", received: " + hexString, "hexString");
float r = Convert.ToInt32(hexString.Substring(0, 2), 16) / (float)255;
float g = Convert.ToInt32(hexString.Substring(2, 2), 16) / (float)255;
float b = Convert.ToInt32(hexString.Substring(4, 2), 16) / (float)255;
- return new Color(r, g, b);
+ return new Color32F(r, g, b);
}
private class LinkedMesh {
diff --git a/spine-csharp/src/Slot.cs b/spine-csharp/src/Slot.cs
index 3acf1a493..b6d2650df 100644
--- a/spine-csharp/src/Slot.cs
+++ b/spine-csharp/src/Slot.cs
@@ -35,7 +35,7 @@ using System;
namespace Spine {
#if IS_UNITY
- using Color = UnityEngine.Color;
+ using Color32F = UnityEngine.Color;
#endif
///
@@ -54,8 +54,8 @@ namespace Spine {
this.skeleton = skeleton;
bone = skeleton.bones.Items[data.boneData.index];
if (data.setup.GetDarkColor().HasValue) {
- pose.SetDarkColor(new Color());
- constrained.SetDarkColor(new Color());
+ pose.SetDarkColor(new Color32F());
+ constrained.SetDarkColor(new Color32F());
}
SetupPose();
}
@@ -68,8 +68,8 @@ namespace Spine {
this.bone = bone;
this.skeleton = skeleton;
if (data.setup.GetDarkColor().HasValue) {
- pose.SetDarkColor(new Color());
- constrained.SetDarkColor(new Color());
+ pose.SetDarkColor(new Color32F());
+ constrained.SetDarkColor(new Color32F());
}
pose.Set(slot.pose);
}
diff --git a/spine-csharp/src/SlotData.cs b/spine-csharp/src/SlotData.cs
index 403cb8c30..ac1f8f03e 100644
--- a/spine-csharp/src/SlotData.cs
+++ b/spine-csharp/src/SlotData.cs
@@ -34,10 +34,6 @@
using System;
namespace Spine {
-#if IS_UNITY
- using Color = UnityEngine.Color;
-#endif
-
public class SlotData : PosedData {
internal int index;
internal BoneData boneData;
diff --git a/spine-csharp/src/SlotPose.cs b/spine-csharp/src/SlotPose.cs
index f9f0e9232..87930d271 100644
--- a/spine-csharp/src/SlotPose.cs
+++ b/spine-csharp/src/SlotPose.cs
@@ -35,7 +35,7 @@ using System;
namespace Spine {
#if IS_UNITY
- using Color = UnityEngine.Color;
+ using Color32F = UnityEngine.Color;
#endif
///
@@ -47,8 +47,8 @@ namespace Spine {
// Color is a struct, thus set to protected to prevent
// Color color = slot.color; color.a = 0.5; modifying just a copy of the struct instead of the original
// object as in reference implementation.
- protected Color color = new Color(1, 1, 1, 1);
- protected Color? darkColor = null;
+ protected Color32F color = new Color32F(1, 1, 1, 1);
+ protected Color32F? darkColor = null;
internal Attachment attachment; // Not used in setup pose.
internal int sequenceIndex;
internal readonly ExposedList deform = new ExposedList();
@@ -68,13 +68,13 @@ namespace Spine {
/// A copy of the color used to tint the slot's attachment. If is set, this is used as the light color for two
/// color tinting.
- public Color GetColor () {
+ public Color32F GetColor () {
return color;
}
/// Sets the color used to tint the slot's attachment. If is set, this is used as the light color for two
/// color tinting.
- public void SetColor (Color color) {
+ public void SetColor (Color32F color) {
this.color = color;
}
@@ -85,13 +85,13 @@ namespace Spine {
/// A copy of the dark color used to tint the slot's attachment for two color tinting, or null if two color tinting is not used. The dark
/// color's alpha is not used.
- public Color? GetDarkColor () {
+ public Color32F? GetDarkColor () {
return darkColor;
}
/// Sets the dark color used to tint the slot's attachment for two color tinting, or null if two color tinting is not used. The dark
/// color's alpha is not used.
- public void SetDarkColor (Color? darkColor) {
+ public void SetDarkColor (Color32F? darkColor) {
this.darkColor = darkColor;
}
diff --git a/spine-csharp/src/package.json b/spine-csharp/src/package.json
index 7a3874393..9974130f7 100644
--- a/spine-csharp/src/package.json
+++ b/spine-csharp/src/package.json
@@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.spine-csharp",
"displayName": "spine-csharp Runtime",
"description": "This plugin provides the spine-csharp core runtime.",
- "version": "4.3.5",
+ "version": "4.3.6",
"unity": "2018.3",
"author": {
"name": "Esoteric Software",