updated main menu
This commit is contained in:
11
Assets/Scripts/Game/GameSettings.cs
Normal file
11
Assets/Scripts/Game/GameSettings.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName ="Settings",menuName ="ScriptableObjects/New Settings Object",order =1)]
|
||||
public class GameSettings : ScriptableObject
|
||||
{
|
||||
[Range(0,1)]
|
||||
public float volume = 1;
|
||||
|
||||
}
|
11
Assets/Scripts/Game/GameSettings.cs.meta
Normal file
11
Assets/Scripts/Game/GameSettings.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5fbe1a01adadbaa4790f509847965895
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -23,9 +23,25 @@ public class MainMenuManager : MonoBehaviour
|
||||
private readonly List<float> initDilates = new();
|
||||
private bool transitioning;
|
||||
|
||||
[SerializeField] private Animator cameraAnimator;
|
||||
[SerializeField] private MainMenuSettingsManager settingsManager;
|
||||
[SerializeField] private Canvas creditsCanvas;
|
||||
|
||||
private bool isAnimating = false;
|
||||
private bool isDown = false;
|
||||
|
||||
private static MainMenuManager instance;
|
||||
public static MainMenuManager Instance { get { return instance; } }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
|
||||
//initDilate = title.fontSharedMaterials[0].GetFloat(component);
|
||||
initDilate = title.fontMaterials[0].GetFloat(component);
|
||||
|
||||
@ -37,10 +53,16 @@ public class MainMenuManager : MonoBehaviour
|
||||
}
|
||||
|
||||
textList[0].GetComponent<Button>().onClick.AddListener(LoadFirstLevel);
|
||||
textList[1].GetComponent<Button>().onClick.AddListener(LoadSettings);
|
||||
textList[2].GetComponent<Button>().onClick.AddListener(ExitApp);
|
||||
textList[3].GetComponent<Button>().onClick.AddListener(LoadCredits);
|
||||
|
||||
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.Confined;
|
||||
|
||||
this.creditsCanvas.gameObject.SetActive(false);
|
||||
this.settingsManager.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
@ -89,4 +111,31 @@ public class MainMenuManager : MonoBehaviour
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
private void LoadSettings()
|
||||
{
|
||||
ToggleCamera();
|
||||
this.creditsCanvas.gameObject.SetActive(false);
|
||||
this.settingsManager.gameObject.SetActive(true);
|
||||
}
|
||||
private void LoadCredits()
|
||||
{
|
||||
ToggleCamera();
|
||||
this.creditsCanvas.gameObject.SetActive(true);
|
||||
this.settingsManager.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void ToggleCamera()
|
||||
{
|
||||
|
||||
if(!isAnimating)
|
||||
StartCoroutine(_ToggleCamera());
|
||||
}
|
||||
private IEnumerator _ToggleCamera()
|
||||
{
|
||||
cameraAnimator.Play(isDown?"CameraUp":"CameraDown");
|
||||
isAnimating = true;
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
isAnimating = false;
|
||||
isDown = !isDown;
|
||||
}
|
||||
}
|
25
Assets/Scripts/MainMenu/MainMenuSettingsManager.cs
Normal file
25
Assets/Scripts/MainMenu/MainMenuSettingsManager.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MainMenuSettingsManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private GameSettings settings;
|
||||
|
||||
[SerializeField]
|
||||
private Button volumeButton;
|
||||
[SerializeField] private Button returnButton;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
returnButton.onClick.AddListener(MainMenuManager.Instance.ToggleCamera);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/MainMenu/MainMenuSettingsManager.cs.meta
Normal file
11
Assets/Scripts/MainMenu/MainMenuSettingsManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06ae6e4d2715950408a898e518ab5c98
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user