Make color panel UIs use one script instead of 3
This commit is contained in:
@@ -2432,7 +2432,7 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 346076455}
|
m_GameObject: {fileID: 346076455}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: b2570aea461bc94f28157a7cc7d381ef, type: 3}
|
m_Script: {fileID: 11500000, guid: be845a3d96a3e4c4db8a150c05c99b86, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
rSlider: {fileID: 415708120}
|
rSlider: {fileID: 415708120}
|
||||||
@@ -6215,7 +6215,7 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 989561978}
|
m_GameObject: {fileID: 989561978}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 65f6bd5c95bc89f17b1446eb992dc697, type: 3}
|
m_Script: {fileID: 11500000, guid: be845a3d96a3e4c4db8a150c05c99b86, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
rSlider: {fileID: 139542974}
|
rSlider: {fileID: 139542974}
|
||||||
@@ -6460,6 +6460,8 @@ MonoBehaviour:
|
|||||||
overlay13: {fileID: 1736703}
|
overlay13: {fileID: 1736703}
|
||||||
overlay14: {fileID: 1798643177}
|
overlay14: {fileID: 1798643177}
|
||||||
previewBirdObject: {fileID: 2072730781}
|
previewBirdObject: {fileID: 2072730781}
|
||||||
|
iconColorPanel: {fileID: 346076460}
|
||||||
|
overlayColorPanel: {fileID: 989561983}
|
||||||
--- !u!1 &1098647304
|
--- !u!1 &1098647304
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -720,7 +720,7 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 96579867}
|
m_GameObject: {fileID: 96579867}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 851d6819986698659a53cdf0cb057649, type: 3}
|
m_Script: {fileID: 11500000, guid: be845a3d96a3e4c4db8a150c05c99b86, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
rSlider: {fileID: 1003646544}
|
rSlider: {fileID: 1003646544}
|
||||||
@@ -728,11 +728,10 @@ MonoBehaviour:
|
|||||||
bSlider: {fileID: 1502389286}
|
bSlider: {fileID: 1502389286}
|
||||||
colorPickerUI: {fileID: 1647778840}
|
colorPickerUI: {fileID: 1647778840}
|
||||||
manualModeUI: {fileID: 804553763}
|
manualModeUI: {fileID: 804553763}
|
||||||
settingsUI: {fileID: 876482803}
|
|
||||||
hexValue: {fileID: 1509429880}
|
hexValue: {fileID: 1509429880}
|
||||||
|
previewImage: {fileID: 0}
|
||||||
resetButton: {fileID: 877006207}
|
resetButton: {fileID: 877006207}
|
||||||
switchModeButton: {fileID: 1009561871}
|
switchModeButton: {fileID: 1009561871}
|
||||||
previewButton: {fileID: 253951279}
|
|
||||||
--- !u!1 &99615552
|
--- !u!1 &99615552
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1592,6 +1591,9 @@ MonoBehaviour:
|
|||||||
setting4toggle: {fileID: 1304594480}
|
setting4toggle: {fileID: 1304594480}
|
||||||
musicSlider: {fileID: 382287572}
|
musicSlider: {fileID: 382287572}
|
||||||
sfxSlider: {fileID: 964986325}
|
sfxSlider: {fileID: 964986325}
|
||||||
|
bgColorPanel: {fileID: 96579872}
|
||||||
|
bgPreviewModePanel: {fileID: 253951279}
|
||||||
|
settingsUI: {fileID: 876482803}
|
||||||
--- !u!1 &372795356
|
--- !u!1 &372795356
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
using System;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class IconsMenuBirdColorPanel : MonoBehaviour
|
public class ColorPanel : MonoBehaviour
|
||||||
{
|
{
|
||||||
public Slider rSlider;
|
public Slider rSlider;
|
||||||
public Slider gSlider;
|
public Slider gSlider;
|
||||||
@@ -14,13 +15,13 @@ public class IconsMenuBirdColorPanel : MonoBehaviour
|
|||||||
public Image previewImage;
|
public Image previewImage;
|
||||||
public Button resetButton;
|
public Button resetButton;
|
||||||
public Button switchModeButton;
|
public Button switchModeButton;
|
||||||
|
public event Action<JArray> OnColorChanged;
|
||||||
|
|
||||||
void Awake()
|
public void Init(JArray color, Color defaultColor)
|
||||||
{
|
{
|
||||||
var birdColor = BazookaManager.Instance.GetColorSettingIcon();
|
rSlider.value = (int)color[0];
|
||||||
rSlider.value = (int)birdColor[0];
|
gSlider.value = (int)color[1];
|
||||||
gSlider.value = (int)birdColor[1];
|
bSlider.value = (int)color[2];
|
||||||
bSlider.value = (int)birdColor[2];
|
|
||||||
|
|
||||||
SyncAll();
|
SyncAll();
|
||||||
|
|
||||||
@@ -42,7 +43,9 @@ public class IconsMenuBirdColorPanel : MonoBehaviour
|
|||||||
|
|
||||||
resetButton.onClick.AddListener(() =>
|
resetButton.onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
rSlider.value = gSlider.value = bSlider.value = 255;
|
rSlider.value = defaultColor.r * 255f;
|
||||||
|
gSlider.value = defaultColor.g * 255f;
|
||||||
|
bSlider.value = defaultColor.b * 255f;
|
||||||
});
|
});
|
||||||
|
|
||||||
switchModeButton.onClick.AddListener(() =>
|
switchModeButton.onClick.AddListener(() =>
|
||||||
@@ -67,9 +70,9 @@ public class IconsMenuBirdColorPanel : MonoBehaviour
|
|||||||
|
|
||||||
if (!fromPicker) colorPickerUI.SetSelectedColor(rSlider.value, gSlider.value, bSlider.value);
|
if (!fromPicker) colorPickerUI.SetSelectedColor(rSlider.value, gSlider.value, bSlider.value);
|
||||||
|
|
||||||
previewImage.color = col;
|
if (previewImage != null) previewImage.color = col;
|
||||||
hexValue.SetTextWithoutNotify("#" + ColorUtility.ToHtmlStringRGB(col));
|
hexValue.SetTextWithoutNotify("#" + ColorUtility.ToHtmlStringRGB(col));
|
||||||
BazookaManager.Instance.SetColorSettingIcon(new JArray(
|
OnColorChanged?.Invoke(new JArray(
|
||||||
(int)rSlider.value,
|
(int)rSlider.value,
|
||||||
(int)gSlider.value,
|
(int)gSlider.value,
|
||||||
(int)bSlider.value
|
(int)bSlider.value
|
||||||
2
Assets/Scripts/ColorPanel.cs.meta
Normal file
2
Assets/Scripts/ColorPanel.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: be845a3d96a3e4c4db8a150c05c99b86
|
||||||
@@ -37,9 +37,22 @@ public class Iconsmenu : MonoBehaviour
|
|||||||
public Button overlay13;
|
public Button overlay13;
|
||||||
public Button overlay14;
|
public Button overlay14;
|
||||||
public GameObject previewBirdObject;
|
public GameObject previewBirdObject;
|
||||||
|
public ColorPanel iconColorPanel;
|
||||||
|
public ColorPanel overlayColorPanel;
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
iconColorPanel.Init(BazookaManager.Instance.GetColorSettingIcon(), Color.white);
|
||||||
|
iconColorPanel.OnColorChanged += color =>
|
||||||
|
{
|
||||||
|
BazookaManager.Instance.SetColorSettingIcon(color);
|
||||||
|
};
|
||||||
|
overlayColorPanel.Init(BazookaManager.Instance.GetColorSettingOverlay(), Color.white);
|
||||||
|
overlayColorPanel.OnColorChanged += color =>
|
||||||
|
{
|
||||||
|
BazookaManager.Instance.SetColorSettingOverlay(color);
|
||||||
|
};
|
||||||
|
|
||||||
defaultIcon = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0);
|
defaultIcon = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0);
|
||||||
icon1.transform.GetChild(0).GetComponent<Image>().sprite = defaultIcon;
|
icon1.transform.GetChild(0).GetComponent<Image>().sprite = defaultIcon;
|
||||||
SwitchToIcon();
|
SwitchToIcon();
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b2570aea461bc94f28157a7cc7d381ef
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using TMPro;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
public class IconsMenuOverlayColorPanel : MonoBehaviour
|
|
||||||
{
|
|
||||||
public Slider rSlider;
|
|
||||||
public Slider gSlider;
|
|
||||||
public Slider bSlider;
|
|
||||||
public ColorPickerUI colorPickerUI;
|
|
||||||
public GameObject manualModeUI;
|
|
||||||
public TMP_InputField hexValue;
|
|
||||||
public Image previewImage;
|
|
||||||
public Button resetButton;
|
|
||||||
public Button switchModeButton;
|
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
var overlayColor = BazookaManager.Instance.GetColorSettingOverlay();
|
|
||||||
rSlider.value = (int)overlayColor[0];
|
|
||||||
gSlider.value = (int)overlayColor[1];
|
|
||||||
bSlider.value = (int)overlayColor[2];
|
|
||||||
|
|
||||||
SyncAll();
|
|
||||||
|
|
||||||
rSlider.onValueChanged.AddListener(_ => SyncAll());
|
|
||||||
gSlider.onValueChanged.AddListener(_ => SyncAll());
|
|
||||||
bSlider.onValueChanged.AddListener(_ => SyncAll());
|
|
||||||
|
|
||||||
hexValue.onValueChanged.AddListener(value =>
|
|
||||||
{
|
|
||||||
var hex = value.StartsWith("#") ? value : "#" + value;
|
|
||||||
if (hex.Length == 7 && ColorUtility.TryParseHtmlString(hex, out var col))
|
|
||||||
{
|
|
||||||
rSlider.SetValueWithoutNotify(col.r * 255f);
|
|
||||||
gSlider.SetValueWithoutNotify(col.g * 255f);
|
|
||||||
bSlider.SetValueWithoutNotify(col.b * 255f);
|
|
||||||
SyncAll();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
resetButton.onClick.AddListener(() =>
|
|
||||||
{
|
|
||||||
rSlider.value = gSlider.value = bSlider.value = 255;
|
|
||||||
});
|
|
||||||
|
|
||||||
switchModeButton.onClick.AddListener(() =>
|
|
||||||
{
|
|
||||||
bool enableManual = !manualModeUI.activeSelf;
|
|
||||||
manualModeUI.SetActive(enableManual);
|
|
||||||
colorPickerUI.gameObject.SetActive(!enableManual);
|
|
||||||
});
|
|
||||||
|
|
||||||
colorPickerUI.OnColorChanged += color =>
|
|
||||||
{
|
|
||||||
rSlider.SetValueWithoutNotify(color.r * 255);
|
|
||||||
gSlider.SetValueWithoutNotify(color.g * 255);
|
|
||||||
bSlider.SetValueWithoutNotify(color.b * 255);
|
|
||||||
SyncAll(fromPicker: true);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void SyncAll(bool fromPicker = false)
|
|
||||||
{
|
|
||||||
var col = new Color(rSlider.value / 255f, gSlider.value / 255f, bSlider.value / 255f);
|
|
||||||
|
|
||||||
if (!fromPicker) colorPickerUI.SetSelectedColor(rSlider.value, gSlider.value, bSlider.value);
|
|
||||||
|
|
||||||
previewImage.color = col;
|
|
||||||
hexValue.SetTextWithoutNotify("#" + ColorUtility.ToHtmlStringRGB(col));
|
|
||||||
BazookaManager.Instance.SetColorSettingOverlay(new JArray(
|
|
||||||
(int)rSlider.value,
|
|
||||||
(int)gSlider.value,
|
|
||||||
(int)bSlider.value
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 65f6bd5c95bc89f17b1446eb992dc697
|
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
@@ -9,9 +10,26 @@ public class SettingsMenu : MonoBehaviour
|
|||||||
public Toggle setting4toggle;
|
public Toggle setting4toggle;
|
||||||
public Slider musicSlider;
|
public Slider musicSlider;
|
||||||
public Slider sfxSlider;
|
public Slider sfxSlider;
|
||||||
|
public ColorPanel bgColorPanel;
|
||||||
|
public Button bgPreviewModePanel;
|
||||||
|
public GameObject settingsUI;
|
||||||
|
|
||||||
private void Awake()
|
private void Start()
|
||||||
{
|
{
|
||||||
|
bgColorPanel.Init(BazookaManager.Instance.GetColorSettingBackground(), new Color(58 / 255f, 58 / 255f, 58 / 255f));
|
||||||
|
bgColorPanel.OnColorChanged += color =>
|
||||||
|
{
|
||||||
|
BazookaManager.Instance.SetColorSettingBackground(color);
|
||||||
|
if (!settingsUI.activeSelf) Camera.main.backgroundColor = new Color((int)color[0] / 255f, (int)color[1] / 255f, (int)color[2] / 255f);
|
||||||
|
};
|
||||||
|
bgPreviewModePanel.onClick.AddListener(() =>
|
||||||
|
{
|
||||||
|
settingsUI.SetActive(!settingsUI.activeSelf);
|
||||||
|
var value = BazookaManager.Instance.GetColorSettingBackground();
|
||||||
|
Camera.main.backgroundColor = !settingsUI.activeSelf ? new Color((int)value[0] / 255f, (int)value[1] / 255f, (int)value[2] / 255f) : new Color(24 / 255f, 24 / 255f, 24 / 255f);
|
||||||
|
bgPreviewModePanel.transform.GetChild(0).GetComponent<TMP_Text>().text = settingsUI.activeSelf ? "Preview On" : "Preview Off";
|
||||||
|
});
|
||||||
|
|
||||||
musicSlider.value = BazookaManager.Instance.GetSettingMusicVolume();
|
musicSlider.value = BazookaManager.Instance.GetSettingMusicVolume();
|
||||||
sfxSlider.value = BazookaManager.Instance.GetSettingSFXVolume();
|
sfxSlider.value = BazookaManager.Instance.GetSettingSFXVolume();
|
||||||
if (!Application.isMobilePlatform)
|
if (!Application.isMobilePlatform)
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using TMPro;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
public class SettingsMenuBgColorPanel : MonoBehaviour
|
|
||||||
{
|
|
||||||
public Slider rSlider;
|
|
||||||
public Slider gSlider;
|
|
||||||
public Slider bSlider;
|
|
||||||
public ColorPickerUI colorPickerUI;
|
|
||||||
public GameObject manualModeUI;
|
|
||||||
public GameObject settingsUI;
|
|
||||||
public TMP_InputField hexValue;
|
|
||||||
public Button resetButton;
|
|
||||||
public Button switchModeButton;
|
|
||||||
public Button previewButton;
|
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
var backgroundColor = BazookaManager.Instance.GetColorSettingBackground();
|
|
||||||
rSlider.value = (int)backgroundColor[0];
|
|
||||||
gSlider.value = (int)backgroundColor[1];
|
|
||||||
bSlider.value = (int)backgroundColor[2];
|
|
||||||
|
|
||||||
SyncAll();
|
|
||||||
|
|
||||||
rSlider.onValueChanged.AddListener(_ => SyncAll());
|
|
||||||
gSlider.onValueChanged.AddListener(_ => SyncAll());
|
|
||||||
bSlider.onValueChanged.AddListener(_ => SyncAll());
|
|
||||||
|
|
||||||
hexValue.onValueChanged.AddListener(value =>
|
|
||||||
{
|
|
||||||
var hex = value.StartsWith("#") ? value : "#" + value;
|
|
||||||
if (hex.Length == 7 && ColorUtility.TryParseHtmlString(hex, out var col))
|
|
||||||
{
|
|
||||||
rSlider.SetValueWithoutNotify(col.r * 255f);
|
|
||||||
gSlider.SetValueWithoutNotify(col.g * 255f);
|
|
||||||
bSlider.SetValueWithoutNotify(col.b * 255f);
|
|
||||||
SyncAll();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
resetButton.onClick.AddListener(() =>
|
|
||||||
{
|
|
||||||
rSlider.value = gSlider.value = bSlider.value = 58;
|
|
||||||
});
|
|
||||||
|
|
||||||
switchModeButton.onClick.AddListener(() =>
|
|
||||||
{
|
|
||||||
bool enableManual = !manualModeUI.activeSelf;
|
|
||||||
manualModeUI.SetActive(enableManual);
|
|
||||||
colorPickerUI.gameObject.SetActive(!enableManual);
|
|
||||||
});
|
|
||||||
|
|
||||||
previewButton.onClick.AddListener(() =>
|
|
||||||
{
|
|
||||||
settingsUI.SetActive(!settingsUI.activeSelf);
|
|
||||||
Camera.main.backgroundColor = !settingsUI.activeSelf ? new Color(rSlider.value / 255f, gSlider.value / 255f, bSlider.value / 255f) : new Color(24 / 255f, 24 / 255f, 24 / 255f);
|
|
||||||
previewButton.transform.GetChild(0).GetComponent<TMP_Text>().text = settingsUI.activeSelf ? "Preview On" : "Preview Off";
|
|
||||||
});
|
|
||||||
|
|
||||||
colorPickerUI.OnColorChanged += color =>
|
|
||||||
{
|
|
||||||
rSlider.SetValueWithoutNotify(color.r * 255);
|
|
||||||
gSlider.SetValueWithoutNotify(color.g * 255);
|
|
||||||
bSlider.SetValueWithoutNotify(color.b * 255);
|
|
||||||
SyncAll(fromPicker: true);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void SyncAll(bool fromPicker = false)
|
|
||||||
{
|
|
||||||
var col = new Color(rSlider.value / 255f, gSlider.value / 255f, bSlider.value / 255f);
|
|
||||||
|
|
||||||
if (!fromPicker) colorPickerUI.SetSelectedColor(rSlider.value, gSlider.value, bSlider.value);
|
|
||||||
if (!settingsUI.activeSelf) Camera.main.backgroundColor = col;
|
|
||||||
|
|
||||||
hexValue.SetTextWithoutNotify("#" + ColorUtility.ToHtmlStringRGB(col));
|
|
||||||
BazookaManager.Instance.SetColorSettingBackground(new JArray(
|
|
||||||
(int)rSlider.value,
|
|
||||||
(int)gSlider.value,
|
|
||||||
(int)bSlider.value
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 851d6819986698659a53cdf0cb057649
|
|
||||||
Reference in New Issue
Block a user