mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
[unity] Minor cleanup.
This commit is contained in:
parent
8a2972b5bb
commit
b4707e4441
@ -166,16 +166,18 @@ namespace Spine.Unity.Modules {
|
|||||||
|
|
||||||
//based on UnifyWiki http://wiki.unity3d.com/index.php?title=HexConverter
|
//based on UnifyWiki http://wiki.unity3d.com/index.php?title=HexConverter
|
||||||
static Color32 HexToColor (string hex) {
|
static Color32 HexToColor (string hex) {
|
||||||
|
const System.Globalization.NumberStyles HexStyle = System.Globalization.NumberStyles.HexNumber;
|
||||||
|
|
||||||
if (hex.Length < 6)
|
if (hex.Length < 6)
|
||||||
return Color.magenta;
|
return Color.magenta;
|
||||||
|
|
||||||
hex = hex.Replace("#", "");
|
hex = hex.Replace("#", "");
|
||||||
byte r = byte.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
|
byte r = byte.Parse(hex.Substring(0, 2), HexStyle);
|
||||||
byte g = byte.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
|
byte g = byte.Parse(hex.Substring(2, 2), HexStyle);
|
||||||
byte b = byte.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
|
byte b = byte.Parse(hex.Substring(4, 2), HexStyle);
|
||||||
byte a = 0xFF;
|
byte a = 0xFF;
|
||||||
if (hex.Length == 8)
|
if (hex.Length == 8)
|
||||||
a = byte.Parse(hex.Substring(6, 2), System.Globalization.NumberStyles.HexNumber);
|
a = byte.Parse(hex.Substring(6, 2), HexStyle);
|
||||||
|
|
||||||
return new Color32(r, g, b, a);
|
return new Color32(r, g, b, a);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user