Finish color changing UIS

This commit is contained in:
2025-09-07 10:34:01 -07:00
parent 9485f65f16
commit dc48de0d1f
16 changed files with 6164 additions and 171 deletions

View File

@@ -1,4 +1,3 @@
using Newtonsoft.Json.Linq;
using TMPro;
using UnityEngine;
@@ -8,35 +7,78 @@ public class CustomColorObject : MonoBehaviour
{
public ColorObjectType type;
public bool invert;
public Color addMore;
public bool reverseAdd;
Color ApplyModifiers(Color baseColor)
{
if (invert) baseColor = new(1f - baseColor.r, 1f - baseColor.g, 1f - baseColor.b);
if (reverseAdd)
{
baseColor.r = Mathf.Clamp01(baseColor.r - addMore.r);
baseColor.g = Mathf.Clamp01(baseColor.g - addMore.g);
baseColor.b = Mathf.Clamp01(baseColor.b - addMore.b);
}
else
{
baseColor.r = Mathf.Clamp01(baseColor.r + addMore.r);
baseColor.g = Mathf.Clamp01(baseColor.g + addMore.g);
baseColor.b = Mathf.Clamp01(baseColor.b + addMore.b);
}
return baseColor;
}
public void SetColor()
{
JArray color = null;
Color colorType = Color.white;
switch (type)
{
case ColorObjectType.InGameBackgroundColor:
JArray color = BazookaManager.Instance.GetColorSettingBackground();
Color colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
if (invert) colorType = new(1f - colorType.r, 1f - colorType.g, 1f - colorType.b);
color = BazookaManager.Instance.GetColorSettingBackground();
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
colorType = ApplyModifiers(colorType);
gameObject.GetComponent<Camera>().backgroundColor = colorType;
break;
case ColorObjectType.MenuBackgroundColor:
color = BazookaManager.Instance.GetColorSettingMenuBackground();
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
if (invert) colorType = new(1f - colorType.r, 1f - colorType.g, 1f - colorType.b);
colorType = ApplyModifiers(colorType);
gameObject.GetComponent<Camera>().backgroundColor = colorType;
break;
case ColorObjectType.MenuBackgroundColorImage:
color = BazookaManager.Instance.GetColorSettingMenuBackground();
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
colorType = ApplyModifiers(colorType);
gameObject.GetComponent<Image>().color = colorType;
break;
case ColorObjectType.ButtonColor:
color = BazookaManager.Instance.GetColorSettingButton();
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
if (invert) colorType = new(1f - colorType.r, 1f - colorType.g, 1f - colorType.b);
colorType = ApplyModifiers(colorType);
gameObject.GetComponent<Image>().color = colorType;
break;
case ColorObjectType.ButtonColorText:
color = BazookaManager.Instance.GetColorSettingButton();
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
colorType = ApplyModifiers(colorType);
gameObject.GetComponent<TMP_Text>().color = colorType;
break;
case ColorObjectType.TextColor:
color = BazookaManager.Instance.GetColorSettingText();
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
if (invert) colorType = new(1f - colorType.r, 1f - colorType.g, 1f - colorType.b);
colorType = ApplyModifiers(colorType);
gameObject.GetComponent<TMP_Text>().color = colorType;
break;
case ColorObjectType.TextColorImage:
color = BazookaManager.Instance.GetColorSettingText();
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
colorType = ApplyModifiers(colorType);
gameObject.GetComponent<Image>().color = colorType;
break;
}
}