added brightness method

This commit is contained in:
DerTyp187
2021-12-21 22:07:09 +01:00
parent da164e4e90
commit 405f59f764
2 changed files with 146 additions and 1 deletions

View File

@@ -8,7 +8,6 @@ public class MenuPanelSwitch : MonoBehaviour
[SerializeField] private GameObject MainPanel, JoinPanel, HostPanel, OptionsPanel;
[SerializeField] private Button JoinBtn, HostBtn, OptionsBtn;
private Button BackBtn;
private void Start()
{
@@ -23,7 +22,9 @@ public class MenuPanelSwitch : MonoBehaviour
HostPanel.SetActive(false);
OptionsPanel.SetActive(false);
SetBackgroundBrightness(1f);
MainPanel.SetActive(true);
}
public void TurnAllOff()
@@ -32,24 +33,32 @@ public class MenuPanelSwitch : MonoBehaviour
HostPanel.SetActive(false);
OptionsPanel.SetActive(false);
MainPanel.SetActive(false);
}
public void SwitchJoinPanel()
{
TurnAllOff();
SetBackgroundBrightness(0.5f);
JoinPanel.SetActive(true);
}
public void SwitchHostPanel()
{
TurnAllOff();
SetBackgroundBrightness(0.5f);
HostPanel.SetActive(true);
}
public void SwitchOptionsPanel()
{
TurnAllOff();
SetBackgroundBrightness(0.5f);
OptionsPanel.SetActive(true);
}
void SetBackgroundBrightness(float b) // 0.0 -> 1
{
GetComponent<Image>().color = new Color(b, b, b);
}
}