[csharp] Split and renamed Color struct and alias name to Colo32F to avoid name clash in XNA/Monogame.

This commit is contained in:
Harald Csaszar 2025-06-30 13:30:11 +02:00
parent cba2d4d0d7
commit f1350db84d
17 changed files with 263 additions and 95 deletions

View File

@ -36,7 +36,7 @@ using System.Collections.Generic;
namespace Spine {
#if IS_UNITY
using Color = UnityEngine.Color;
using Color32F = UnityEngine.Color;
#endif
/// <summary>
@ -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;

View File

@ -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 {
/// </summary>
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; }

View File

@ -35,7 +35,7 @@ using System;
namespace Spine {
#if IS_UNITY
using Color = UnityEngine.Color;
using Color32F = UnityEngine.Color;
#endif
/// <summary>Attachment that displays a texture region using a mesh.</summary>
@ -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; } }

View File

@ -35,7 +35,7 @@ using System;
namespace Spine {
#if IS_UNITY
using Color = UnityEngine.Color;
using Color32F = UnityEngine.Color;
#endif
/// <summary>Attachment that displays a texture region.</summary>
@ -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; }

View File

@ -1,2 +0,0 @@
fileFormatVersion: 2
guid: 445e5522c6d723a4bb98798781daa7d0

View File

@ -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 {
/// <summary>
/// 32 bit floating point color to be used with XNA/Monogame.
/// </summary>
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

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 3eb49ca43afc71d41bdadef9155891e0

View File

@ -31,14 +31,15 @@
#define IS_UNITY
#endif
#if !IS_UNITY
namespace Spine {
#if IS_UNITY
using Color = UnityEngine.Color;
#else
public struct Color {
/// <summary>
/// 32 bit floating point color to be used with other game toolkits than Unity and XNA/Monogame.
/// </summary>
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

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b6c7cc15ba45b0045a609f65b360220a

View File

@ -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

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c96d35d696c85a44ab68037d151dde5d

View File

@ -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<IPosedInternal> resetCache = new ExposedList<IPosedInternal>(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;
/// <summary>Private to enforce usage of ScaleY getter taking Bone.yDown into account.</summary>
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 {
}
/// <returns>A copy of the color to tint all the skeleton's attachments.</returns>
public Color GetColor () {
public Color32F GetColor () {
return color;
}
/// <summary>Sets the color to tint all the skeleton's attachments.</summary>
public void SetColor (Color color) {
public void SetColor (Color32F color) {
this.color = color;
}
/// <summary>
/// A convenience method for setting the skeleton color. The color can also be set by
/// <see cref="SetColor(Color)"/>
/// <see cref="SetColor(Color32F)"/>
/// </summary>
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);
}
/// <summary><para> Scales the entire skeleton on the X axis.</para>

View File

@ -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 {

View File

@ -35,7 +35,7 @@ using System;
namespace Spine {
#if IS_UNITY
using Color = UnityEngine.Color;
using Color32F = UnityEngine.Color;
#endif
/// <summary>
@ -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);
}

View File

@ -34,10 +34,6 @@
using System;
namespace Spine {
#if IS_UNITY
using Color = UnityEngine.Color;
#endif
public class SlotData : PosedData<SlotPose> {
internal int index;
internal BoneData boneData;

View File

@ -35,7 +35,7 @@ using System;
namespace Spine {
#if IS_UNITY
using Color = UnityEngine.Color;
using Color32F = UnityEngine.Color;
#endif
/// <summary>
@ -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<float> deform = new ExposedList<float>();
@ -68,13 +68,13 @@ namespace Spine {
/// <returns>A copy of the color used to tint the slot's attachment. If <see cref="DarkColor"/> is set, this is used as the light color for two
/// color tinting.</returns>
public Color GetColor () {
public Color32F GetColor () {
return color;
}
/// <summary>Sets the color used to tint the slot's attachment. If <see cref="DarkColor"/> is set, this is used as the light color for two
/// color tinting.</summary>
public void SetColor (Color color) {
public void SetColor (Color32F color) {
this.color = color;
}
@ -85,13 +85,13 @@ namespace Spine {
/// <returns>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.</returns>
public Color? GetDarkColor () {
public Color32F? GetDarkColor () {
return darkColor;
}
/// <summary>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.</summary>
public void SetDarkColor (Color? darkColor) {
public void SetDarkColor (Color32F? darkColor) {
this.darkColor = darkColor;
}

View File

@ -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",