So I’m making a game kind of like a mini PC.
In the settings there is an option to change the background color, with 9 colors. But whenever I click any of the colors, it changes to just white, even though in code, all of the rgba colors are correct.
If anybody wants code, here:
BGColour.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class BGColour : MonoBehaviour {
public enum BGColourTypes
{
Orange_Default,
Blue,
Red,
Green,
Purple,
Yellow,
Black,
White,
Pink
}
public BGColourTypes BgColourTypes;
public Camera desktop;
public void BGColourChange()
{
string colour = PlayerPrefs.GetString("colour", "Orange");
if (colour == "Orange")
{
BgColourTypes = BGColourTypes.Orange_Default;
PlayerPrefs.SetString("colour", "Orange");
} else if (colour == "Blue")
{
BgColourTypes = BGColourTypes.Blue;
PlayerPrefs.SetString("colour", "Blue");
} else if (colour == "Red")
{
BgColourTypes = BGColourTypes.Red;
PlayerPrefs.SetString("colour", "Red");
} else if (colour == "Green")
{
BgColourTypes = BGColourTypes.Green;
PlayerPrefs.SetString("colour", "Green");
} else if (colour == "Purple")
{
BgColourTypes = BGColourTypes.Purple;
PlayerPrefs.SetString("colour", "Purple");
} else if (colour == "Yellow")
{
BgColourTypes = BGColourTypes.Yellow;
PlayerPrefs.SetString("colour", "Yellow");
} else if (colour == "BLack")
{
BgColourTypes = BGColourTypes.Black;
PlayerPrefs.SetString("colour", "Black");
} else if (colour == "White")
{
BgColourTypes = BGColourTypes.White;
PlayerPrefs.SetString("colour", "White");
} else if (colour == "Pink")
{
BgColourTypes = BGColourTypes.Pink;
PlayerPrefs.SetString("colour", "Pink");
}
}
void Update()
{
if (BgColourTypes == BGColourTypes.Orange_Default)
{
desktop.backgroundColor = new Color(255, 179, 55, 255);
}
else if (BgColourTypes == BGColourTypes.Blue)
{
desktop.backgroundColor = new Color(55, 131, 255, 255);
}
else if (BgColourTypes == BGColourTypes.Red)
{
desktop.backgroundColor = new Color(255, 55, 55, 255);
}
else if (BgColourTypes == BGColourTypes.Green)
{
desktop.backgroundColor = new Color(0, 216, 10, 255);
}
else if (BgColourTypes == BGColourTypes.Purple)
{
desktop.backgroundColor = new Color(186, 55, 255, 255);
}
else if (BgColourTypes == BGColourTypes.Yellow)
{
desktop.backgroundColor = new Color(255, 241, 55, 255);
}
else if (BgColourTypes == BGColourTypes.Black)
{
desktop.backgroundColor = new Color(0, 0, 0, 255);
}
else if (BgColourTypes == BGColourTypes.White)
{
desktop.backgroundColor = new Color(255, 255, 255, 255);
}
else if (BgColourTypes == BGColourTypes.Pink)
{
desktop.backgroundColor = new Color(255, 120, 251, 255);
}
}
}
Thanks