Fix alpha value not being respected with custom object color object script, and also add a new type
This commit is contained in:
@@ -32,8 +32,10 @@ public class CustomColorObject : MonoBehaviour
|
|||||||
|
|
||||||
public void SetColor()
|
public void SetColor()
|
||||||
{
|
{
|
||||||
|
dynamic obj = null;
|
||||||
JArray color = null;
|
JArray color = null;
|
||||||
Color colorType = Color.white;
|
Color colorType = Color.white;
|
||||||
|
Color currentColor = Color.white;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@@ -41,43 +43,89 @@ public class CustomColorObject : MonoBehaviour
|
|||||||
color = BazookaManager.Instance.GetColorSettingBackground();
|
color = BazookaManager.Instance.GetColorSettingBackground();
|
||||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||||
colorType = ApplyModifiers(colorType);
|
colorType = ApplyModifiers(colorType);
|
||||||
gameObject.GetComponent<Camera>().backgroundColor = colorType;
|
obj = gameObject.GetComponent<Camera>();
|
||||||
|
currentColor = obj.backgroundColor;
|
||||||
|
currentColor.r = colorType.r;
|
||||||
|
currentColor.g = colorType.g;
|
||||||
|
currentColor.b = colorType.b;
|
||||||
|
obj.backgroundColor = currentColor;
|
||||||
break;
|
break;
|
||||||
case ColorObjectType.MenuBackgroundColor:
|
case ColorObjectType.MenuBackgroundColor:
|
||||||
color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||||
colorType = ApplyModifiers(colorType);
|
colorType = ApplyModifiers(colorType);
|
||||||
gameObject.GetComponent<Camera>().backgroundColor = colorType;
|
obj = gameObject.GetComponent<Camera>();
|
||||||
|
currentColor = obj.backgroundColor;
|
||||||
|
currentColor.r = colorType.r;
|
||||||
|
currentColor.g = colorType.g;
|
||||||
|
currentColor.b = colorType.b;
|
||||||
|
obj.backgroundColor = currentColor;
|
||||||
break;
|
break;
|
||||||
case ColorObjectType.MenuBackgroundColorImage:
|
case ColorObjectType.MenuBackgroundColorImage:
|
||||||
color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||||
colorType = ApplyModifiers(colorType);
|
colorType = ApplyModifiers(colorType);
|
||||||
gameObject.GetComponent<Image>().color = colorType;
|
obj = gameObject.GetComponent<Image>();
|
||||||
|
currentColor = obj.color;
|
||||||
|
currentColor.r = colorType.r;
|
||||||
|
currentColor.g = colorType.g;
|
||||||
|
currentColor.b = colorType.b;
|
||||||
|
obj.color = currentColor;
|
||||||
|
break;
|
||||||
|
case ColorObjectType.MenuBackgroundColorText:
|
||||||
|
color = BazookaManager.Instance.GetColorSettingMenuBackground();
|
||||||
|
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||||
|
colorType = ApplyModifiers(colorType);
|
||||||
|
obj = gameObject.GetComponent<TMP_Text>();
|
||||||
|
currentColor = obj.color;
|
||||||
|
currentColor.r = colorType.r;
|
||||||
|
currentColor.g = colorType.g;
|
||||||
|
currentColor.b = colorType.b;
|
||||||
|
obj.color = currentColor;
|
||||||
break;
|
break;
|
||||||
case ColorObjectType.ButtonColor:
|
case ColorObjectType.ButtonColor:
|
||||||
color = BazookaManager.Instance.GetColorSettingButton();
|
color = BazookaManager.Instance.GetColorSettingButton();
|
||||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||||
colorType = ApplyModifiers(colorType);
|
colorType = ApplyModifiers(colorType);
|
||||||
gameObject.GetComponent<Image>().color = colorType;
|
obj = gameObject.GetComponent<Image>();
|
||||||
|
currentColor = obj.color;
|
||||||
|
currentColor.r = colorType.r;
|
||||||
|
currentColor.g = colorType.g;
|
||||||
|
currentColor.b = colorType.b;
|
||||||
|
obj.color = currentColor;
|
||||||
break;
|
break;
|
||||||
case ColorObjectType.ButtonColorText:
|
case ColorObjectType.ButtonColorText:
|
||||||
color = BazookaManager.Instance.GetColorSettingButton();
|
color = BazookaManager.Instance.GetColorSettingButton();
|
||||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||||
colorType = ApplyModifiers(colorType);
|
colorType = ApplyModifiers(colorType);
|
||||||
gameObject.GetComponent<TMP_Text>().color = colorType;
|
obj = gameObject.GetComponent<TMP_Text>();
|
||||||
|
currentColor = obj.color;
|
||||||
|
currentColor.r = colorType.r;
|
||||||
|
currentColor.g = colorType.g;
|
||||||
|
currentColor.b = colorType.b;
|
||||||
|
obj.color = currentColor;
|
||||||
break;
|
break;
|
||||||
case ColorObjectType.TextColor:
|
case ColorObjectType.TextColor:
|
||||||
color = BazookaManager.Instance.GetColorSettingText();
|
color = BazookaManager.Instance.GetColorSettingText();
|
||||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||||
colorType = ApplyModifiers(colorType);
|
colorType = ApplyModifiers(colorType);
|
||||||
gameObject.GetComponent<TMP_Text>().color = colorType;
|
obj = gameObject.GetComponent<TMP_Text>();
|
||||||
|
currentColor = obj.color;
|
||||||
|
currentColor.r = colorType.r;
|
||||||
|
currentColor.g = colorType.g;
|
||||||
|
currentColor.b = colorType.b;
|
||||||
|
obj.color = currentColor;
|
||||||
break;
|
break;
|
||||||
case ColorObjectType.TextColorImage:
|
case ColorObjectType.TextColorImage:
|
||||||
color = BazookaManager.Instance.GetColorSettingText();
|
color = BazookaManager.Instance.GetColorSettingText();
|
||||||
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
colorType = new((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||||
colorType = ApplyModifiers(colorType);
|
colorType = ApplyModifiers(colorType);
|
||||||
gameObject.GetComponent<Image>().color = colorType;
|
obj = gameObject.GetComponent<Image>();
|
||||||
|
currentColor = obj.color;
|
||||||
|
currentColor.r = colorType.r;
|
||||||
|
currentColor.g = colorType.g;
|
||||||
|
currentColor.b = colorType.b;
|
||||||
|
obj.color = currentColor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ public enum ColorObjectType
|
|||||||
TextColor,
|
TextColor,
|
||||||
TextColorImage,
|
TextColorImage,
|
||||||
MenuBackgroundColorImage,
|
MenuBackgroundColorImage,
|
||||||
|
MenuBackgroundColorText
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user