mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-13 21:25:09 +00:00
8fa4d74096
* add mouse controller * support different control styles in options deprecate old input check methods * fully functional input actions system * btsds InputAction * blue bear InputAction * more games fix bugs with some input related systems * coin toss re-toss * cheer readers touch * dog ninja touch * multiple games * last of the easy games' touch * more specialized games * specialized games 2 * finish ktb games * remove legacy settings disclaimer * "only" two games left * karate man touch * rockers touch still needs fixes and bad judge strum * DSGuy flicking animation * playstyle chart property * improve performance of minigame preloading * improve look of cursor make assetbundles use chunk-based compression refactor assetbundle loading methods a bit * prime conductor stream playback to stabilize seeking operations * fix air rally swing on pad release * use virtual mouse pointer * add UniTask * make BeatAction use UniTask * implement UniTask to replace some coroutines * add touch style UI elements and effects games now support the ability to define two cursor colours if they need split screen touch inputs * update plugins and buildscript * implement thresholded pointer position clipping * fix clamping * instant show / hide fix discord game SDK crashes
41 lines
1.5 KiB
C#
41 lines
1.5 KiB
C#
using UnityEngine;
|
|
|
|
namespace Starpelly
|
|
{
|
|
public static class Colors
|
|
{
|
|
public static string Color2Hex(this Color color)
|
|
{
|
|
Color32 col = (Color32)color;
|
|
string hex = col.r.ToString("X2") + col.g.ToString("X2") + col.b.ToString("X2");
|
|
return hex;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts a Hexadecimal Color to an RGB Color.
|
|
/// </summary>
|
|
public static Color Hex2RGB(this string hex)
|
|
{
|
|
if (hex is null or "") return Color.black;
|
|
try
|
|
{
|
|
hex = hex.Replace("0x", "");//in case the string is formatted 0xFFFFFF
|
|
hex = hex.Replace("#", "");//in case the string is formatted #FFFFFF
|
|
byte a = 255;//assume fully visible unless specified in hex
|
|
byte r = byte.Parse(hex.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
|
|
byte g = byte.Parse(hex.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
|
|
byte b = byte.Parse(hex.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
|
|
//Only use alpha if the string has enough characters
|
|
if (hex.Length >= 8)
|
|
{
|
|
a = byte.Parse(hex.Substring(6, 2), System.Globalization.NumberStyles.HexNumber);
|
|
}
|
|
return new Color32(r, g, b, a);
|
|
}
|
|
catch
|
|
{
|
|
return Color.black;
|
|
}
|
|
}
|
|
}
|
|
}
|