Add overlay color customization
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -52,6 +52,9 @@ public class AccountLoggedIn : MonoBehaviour
|
|||||||
dataForm.AddField("birdR", PlayerPrefs.GetString("BirdColor", "255;255;255").Split(';')[0]);
|
dataForm.AddField("birdR", PlayerPrefs.GetString("BirdColor", "255;255;255").Split(';')[0]);
|
||||||
dataForm.AddField("birdG", PlayerPrefs.GetString("BirdColor", "255;255;255").Split(';')[1]);
|
dataForm.AddField("birdG", PlayerPrefs.GetString("BirdColor", "255;255;255").Split(';')[1]);
|
||||||
dataForm.AddField("birdB", PlayerPrefs.GetString("BirdColor", "255;255;255").Split(';')[2]);
|
dataForm.AddField("birdB", PlayerPrefs.GetString("BirdColor", "255;255;255").Split(';')[2]);
|
||||||
|
dataForm.AddField("overlayR", PlayerPrefs.GetString("OverlayColor", "255;255;255").Split(';')[0]);
|
||||||
|
dataForm.AddField("overlayG", PlayerPrefs.GetString("OverlayColor", "255;255;255").Split(';')[1]);
|
||||||
|
dataForm.AddField("overlayB", PlayerPrefs.GetString("OverlayColor", "255;255;255").Split(';')[2]);
|
||||||
using UnityWebRequest request = UnityWebRequest.Post(SensitiveInfo.SERVER_DATABASE_PREFIX + "saveAccount.php", dataForm.GetWWWForm());
|
using UnityWebRequest request = UnityWebRequest.Post(SensitiveInfo.SERVER_DATABASE_PREFIX + "saveAccount.php", dataForm.GetWWWForm());
|
||||||
request.SetRequestHeader("Requester", "BerryDashClient");
|
request.SetRequestHeader("Requester", "BerryDashClient");
|
||||||
request.SetRequestHeader("ClientVersion", Application.version);
|
request.SetRequestHeader("ClientVersion", Application.version);
|
||||||
@@ -134,6 +137,7 @@ public class AccountLoggedIn : MonoBehaviour
|
|||||||
PlayerPrefs.SetString("TotalSpeedyBerries", split[8]);
|
PlayerPrefs.SetString("TotalSpeedyBerries", split[8]);
|
||||||
PlayerPrefs.SetString("TotalAttempts", split[9]);
|
PlayerPrefs.SetString("TotalAttempts", split[9]);
|
||||||
PlayerPrefs.SetString("BirdColor", $"{split[10]};{split[11]};{split[12]}");
|
PlayerPrefs.SetString("BirdColor", $"{split[10]};{split[11]};{split[12]}");
|
||||||
|
PlayerPrefs.SetString("OverlayColor", $"{split[13]};{split[14]};{split[15]}");
|
||||||
AccountHandler.UpdateStatusText(loggedInText, "Loaded account data", Color.green);
|
AccountHandler.UpdateStatusText(loggedInText, "Loaded account data", Color.green);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ public class AccountLogin : MonoBehaviour
|
|||||||
PlayerPrefs.SetString("TotalSpeedyBerries", array[11]);
|
PlayerPrefs.SetString("TotalSpeedyBerries", array[11]);
|
||||||
PlayerPrefs.SetString("TotalAttempts", array[12]);
|
PlayerPrefs.SetString("TotalAttempts", array[12]);
|
||||||
PlayerPrefs.SetString("BirdColor", $"{array[13]};{array[14]};{array[15]}");
|
PlayerPrefs.SetString("BirdColor", $"{array[13]};{array[14]};{array[15]}");
|
||||||
|
PlayerPrefs.SetString("OverlayColor", $"{array[16]};{array[17]};{array[18]}");
|
||||||
AccountHandler.instance.SwitchPanel(0);
|
AccountHandler.instance.SwitchPanel(0);
|
||||||
AccountHandler.UpdateStatusText(loginPanelStatusText, "", Color.red);
|
AccountHandler.UpdateStatusText(loginPanelStatusText, "", Color.red);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,6 +167,9 @@ public class ChatroomMenu : MonoBehaviour
|
|||||||
var birdR = rowSplit[6];
|
var birdR = rowSplit[6];
|
||||||
var birdG = rowSplit[7];
|
var birdG = rowSplit[7];
|
||||||
var birdB = rowSplit[8];
|
var birdB = rowSplit[8];
|
||||||
|
var overlayR = rowSplit[9];
|
||||||
|
var overlayG = rowSplit[10];
|
||||||
|
var overlayB = rowSplit[11];
|
||||||
|
|
||||||
if (content.transform.Find("ChatroomRow_" + id) != null)
|
if (content.transform.Find("ChatroomRow_" + id) != null)
|
||||||
{
|
{
|
||||||
@@ -211,9 +214,11 @@ public class ChatroomMenu : MonoBehaviour
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
|
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
|
||||||
|
playerOverlayIcon.color = new Color32(byte.Parse(overlayR), byte.Parse(overlayG), byte.Parse(overlayB), 255);
|
||||||
} catch (Exception)
|
} catch (Exception)
|
||||||
{
|
{
|
||||||
playerIcon.color = Color.white;
|
playerIcon.color = Color.white;
|
||||||
|
playerOverlayIcon.color = Color.white;
|
||||||
}
|
}
|
||||||
rowInfo.name = "ChatroomRow_" + id;
|
rowInfo.name = "ChatroomRow_" + id;
|
||||||
rowInfo.SetActive(true);
|
rowInfo.SetActive(true);
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ public class GamePlayer : MonoBehaviour
|
|||||||
{
|
{
|
||||||
var backgroundColor = PlayerPrefs.GetString("BackgroundColor", "58;58;58").Split(";");
|
var backgroundColor = PlayerPrefs.GetString("BackgroundColor", "58;58;58").Split(";");
|
||||||
var birdColor = PlayerPrefs.GetString("BirdColor", "255;255;255").Split(";");
|
var birdColor = PlayerPrefs.GetString("BirdColor", "255;255;255").Split(";");
|
||||||
|
var overlayColor = PlayerPrefs.GetString("OverlayColor", "255;255;255").Split(";");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Camera.main.backgroundColor = new Color(
|
Camera.main.backgroundColor = new Color(
|
||||||
@@ -56,6 +57,11 @@ public class GamePlayer : MonoBehaviour
|
|||||||
int.Parse(birdColor[1])/255f,
|
int.Parse(birdColor[1])/255f,
|
||||||
int.Parse(birdColor[2])/255f
|
int.Parse(birdColor[2])/255f
|
||||||
);
|
);
|
||||||
|
bird.transform.GetChild(0).GetComponent<SpriteRenderer>().color = new Color(
|
||||||
|
int.Parse(overlayColor[0])/255f,
|
||||||
|
int.Parse(overlayColor[1])/255f,
|
||||||
|
int.Parse(overlayColor[2])/255f
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|||||||
62
Assets/Scripts/IconsMenuOverlayColorPanel.cs
Normal file
62
Assets/Scripts/IconsMenuOverlayColorPanel.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class IconsMenuOverlayColorPanel : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Slider rSlider;
|
||||||
|
public Slider gSlider;
|
||||||
|
public Slider bSlider;
|
||||||
|
public TMP_InputField hexValue;
|
||||||
|
public Image previewImage;
|
||||||
|
public Button resetButton;
|
||||||
|
|
||||||
|
void Awake()
|
||||||
|
{
|
||||||
|
var overlayColor = PlayerPrefs.GetString("OverlayColor", "255;255;255").Split(";");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rSlider.value = int.Parse(overlayColor[0]);
|
||||||
|
gSlider.value = int.Parse(overlayColor[1]);
|
||||||
|
bSlider.value = int.Parse(overlayColor[2]);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Debug.LogError("Invalid OverlayColor format");
|
||||||
|
rSlider.value = 255; gSlider.value = 255; bSlider.value = 255;
|
||||||
|
}
|
||||||
|
SlidersChanged();
|
||||||
|
|
||||||
|
rSlider.onValueChanged.AddListener(_ => SlidersChanged());
|
||||||
|
gSlider.onValueChanged.AddListener(_ => SlidersChanged());
|
||||||
|
bSlider.onValueChanged.AddListener(_ => SlidersChanged());
|
||||||
|
|
||||||
|
hexValue.onValueChanged.AddListener(value =>
|
||||||
|
{
|
||||||
|
var v = value.StartsWith("#") ? value[1..] : value;
|
||||||
|
if (v.Length == 6 && ColorUtility.TryParseHtmlString("#" + v, out var col))
|
||||||
|
{
|
||||||
|
rSlider.SetValueWithoutNotify(col.r * 255f);
|
||||||
|
gSlider.SetValueWithoutNotify(col.g * 255f);
|
||||||
|
bSlider.SetValueWithoutNotify(col.b * 255f);
|
||||||
|
previewImage.color = col;
|
||||||
|
PlayerPrefs.SetString("OverlayColor", $"{(int)(col.r * 255)};{(int)(col.g * 255)};{(int)(col.b * 255)}");
|
||||||
|
PlayerPrefs.Save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
resetButton.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
hexValue.text = "#FFFFFF";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void SlidersChanged()
|
||||||
|
{
|
||||||
|
var col = new Color(rSlider.value/255f, gSlider.value/255f, bSlider.value/255f);
|
||||||
|
previewImage.color = col;
|
||||||
|
hexValue.SetTextWithoutNotify($"#{ColorUtility.ToHtmlStringRGB(col)}");
|
||||||
|
PlayerPrefs.SetString("OverlayColor", $"{(int)rSlider.value};{(int)gSlider.value};{(int)bSlider.value}");
|
||||||
|
PlayerPrefs.Save();
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/IconsMenuOverlayColorPanel.cs.meta
Normal file
2
Assets/Scripts/IconsMenuOverlayColorPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 65f6bd5c95bc89f17b1446eb992dc697
|
||||||
@@ -144,6 +144,9 @@ public class LeaderboardsMenu : MonoBehaviour
|
|||||||
var birdR = split[5];
|
var birdR = split[5];
|
||||||
var birdG = split[6];
|
var birdG = split[6];
|
||||||
var birdB = split[7];
|
var birdB = split[7];
|
||||||
|
var overlayR = split[8];
|
||||||
|
var overlayG = split[9];
|
||||||
|
var overlayB = split[10];
|
||||||
|
|
||||||
var entryInfo = Instantiate(scoreSampleObject, scoreContent.transform);
|
var entryInfo = Instantiate(scoreSampleObject, scoreContent.transform);
|
||||||
var usernameText = entryInfo.transform.GetChild(0).GetComponent<TMP_Text>();
|
var usernameText = entryInfo.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||||
@@ -178,9 +181,11 @@ public class LeaderboardsMenu : MonoBehaviour
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
|
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
|
||||||
|
playerOverlayIcon.color = new Color32(byte.Parse(overlayR), byte.Parse(overlayG), byte.Parse(overlayB), 255);
|
||||||
} catch (Exception)
|
} catch (Exception)
|
||||||
{
|
{
|
||||||
playerIcon.color = Color.white;
|
playerIcon.color = Color.white;
|
||||||
|
playerOverlayIcon.color = Color.white;
|
||||||
}
|
}
|
||||||
entryInfo.SetActive(true);
|
entryInfo.SetActive(true);
|
||||||
}
|
}
|
||||||
@@ -250,6 +255,9 @@ public class LeaderboardsMenu : MonoBehaviour
|
|||||||
var birdR = split[5];
|
var birdR = split[5];
|
||||||
var birdG = split[6];
|
var birdG = split[6];
|
||||||
var birdB = split[7];
|
var birdB = split[7];
|
||||||
|
var overlayR = split[8];
|
||||||
|
var overlayG = split[9];
|
||||||
|
var overlayB = split[10];
|
||||||
|
|
||||||
var entryInfo = Instantiate(berrySampleObject, berryContent.transform);
|
var entryInfo = Instantiate(berrySampleObject, berryContent.transform);
|
||||||
var usernameText = entryInfo.transform.GetChild(0).GetComponent<TMP_Text>();
|
var usernameText = entryInfo.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||||
@@ -284,9 +292,11 @@ public class LeaderboardsMenu : MonoBehaviour
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
|
playerIcon.color = new Color32(byte.Parse(birdR), byte.Parse(birdG), byte.Parse(birdB), 255);
|
||||||
|
playerOverlayIcon.color = new Color32(byte.Parse(overlayR), byte.Parse(overlayG), byte.Parse(overlayB), 255);
|
||||||
} catch (Exception)
|
} catch (Exception)
|
||||||
{
|
{
|
||||||
playerIcon.color = Color.white;
|
playerIcon.color = Color.white;
|
||||||
|
playerOverlayIcon.color = Color.white;
|
||||||
}
|
}
|
||||||
entryInfo.SetActive(true);
|
entryInfo.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user