Skip to content

Commit 5b70834

Browse files
committed
Integrate settings into main menu and update materials
Added Settings ScriptableObject reference to MainMenu and implemented loading/applying user settings (volume, fullscreen) in the options menu. Updated material files to adjust sun direction and cloud color. Removed obsolete UserChoices.choices asset and renamed its meta file for a new scene.
1 parent 874712b commit 5b70834

File tree

8 files changed

+33
-45
lines changed

8 files changed

+33
-45
lines changed

Red Strike/Assets/GameSettings/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public class Settings : ScriptableObject
1010
public float musicVolume = 0.8f;
1111

1212
[Header("Graphics Settings")]
13-
public bool fullscreen = true;
13+
public bool isFullscreen = true;
1414
}
1515
}

Red Strike/Assets/PlanetAtmosphereSystem/AtmosphereMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Material:
4747
- _GunesYonu: {r: -0.91, g: 0.4, b: 3.24, a: 0}
4848
- _RenkUzak: {r: 0, g: 0.10166844, b: 2.152374, a: 1}
4949
- _RenkYakin: {r: 0, g: 5.670685, b: 8, a: 1}
50-
- _SunDirection: {r: 0.17096215, g: 0.1752097, b: -0.96957386, a: 0}
50+
- _SunDirection: {r: -0.12558313, g: -0.2501509, b: 0.96002793, a: 0}
5151
m_BuildTextureStacks: []
5252
m_AllowLocking: 1
5353
--- !u!114 &1522106816477559216

Red Strike/Assets/PlanetAtmosphereSystem/CloudMaterial.mat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ Material:
4141
- _QueueControl: 0
4242
- _QueueOffset: 0
4343
m_Colors:
44-
- _Color: {r: 0, g: 1.0177532, b: 1.5933679, a: 1}
44+
- _Color: {r: 0, g: 3.8274493, b: 5.992155, a: 1}
4545
- _GunesYonu: {r: -1, g: 0, b: 0, a: 0}
46-
- _SunDirection: {r: 0.17096215, g: 0.1752097, b: -0.96957386, a: 0}
46+
- _SunDirection: {r: -0.12558313, g: -0.2501509, b: 0.96002793, a: 0}
4747
m_BuildTextureStacks: []
4848
m_AllowLocking: 1
4949
--- !u!114 &8499732345945835446

Red Strike/Assets/PlanetAtmosphereSystem/FogMaterial.mat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ Material:
5454
- _QueueControl: 0
5555
- _QueueOffset: 0
5656
m_Colors:
57-
- _SunDirection: {r: 0.17096215, g: 0.1752097, b: -0.96957386, a: 0}
57+
- _SunDirection: {r: -0.12558313, g: -0.2501509, b: 0.96002793, a: 0}
5858
m_BuildTextureStacks: []
5959
m_AllowLocking: 1

Red Strike/Assets/Scenes/Menu.unity

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ MonoBehaviour:
354354
m_Name:
355355
m_EditorClassIdentifier:
356356
sunLight: {fileID: 1371548475}
357+
dayDurationInSeconds: 120
357358
atmosphereMaterial: {fileID: 2100000, guid: 2408ec61631a3e24db680f86b5b150a7, type: 2}
358359
cloudMaterial: {fileID: 2100000, guid: 452202a9af21f504594d57e7b894652a, type: 2}
359360
fogMaterial: {fileID: 2100000, guid: cb5b62743c9506845aa26111364535f4, type: 2}
@@ -825,6 +826,7 @@ MonoBehaviour:
825826
shipDuraction: 8
826827
shipStartPosition: {x: 2.24, y: -0.6, z: -19}
827828
targetPosition: {x: 2.24, y: -0.6, z: -9.72}
829+
settings: {fileID: 11400000, guid: e041f970da61a87429a66823e0614072, type: 2}
828830
--- !u!4 &1693417822
829831
Transform:
830832
m_ObjectHideFlags: 0

Red Strike/Assets/UserChoices.choices.meta renamed to Red Strike/Assets/Scenes/New Scene.unity.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Red Strike/Assets/UISystem/MainMenu/MainMenu.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using Unity.Cinemachine;
33
using UnityEngine;
44
using UnityEngine.UIElements;
5+
using GameSettings;
6+
using UnityEngine.SceneManagement;
57

68
namespace UISystem.MainMenu
79
{
@@ -25,6 +27,9 @@ public class MainMenu : MonoBehaviour
2527
public Vector3 shipStartPosition;
2628
public Vector3 targetPosition;
2729

30+
[Header("Settings ScriptableObject")]
31+
public Settings settings;
32+
2833
public enum MenuState { MainMenu, OptionsMenu, CreditsMenu }
2934
private MenuState currentMenuState = MenuState.MainMenu;
3035

@@ -34,6 +39,7 @@ public enum MenuState { MainMenu, OptionsMenu, CreditsMenu }
3439
private VisualElement fadePanel;
3540
private VisualElement settingsOverlay;
3641
private Slider masterVolumeSlider;
42+
private Slider musicVolumeSlider;
3743
private Toggle fullscreenToggle;
3844

3945
private void Awake()
@@ -61,6 +67,7 @@ private void OnEnable()
6167
var backBtn = root.Q<Button>("back-button");
6268
var applyBtn = root.Q<Button>("apply-button");
6369
masterVolumeSlider = root.Q<Slider>("master-volume-slider");
70+
musicVolumeSlider = root.Q<Slider>("music-volume-slider");
6471
fullscreenToggle = root.Q<Toggle>("fullscreen-toggle");
6572

6673
if (backBtn != null) backBtn.clicked += () => BackToMainMenu();
@@ -72,7 +79,7 @@ private void OnEnable()
7279
var quitBtn = root.Q<Button>("quit-button");
7380

7481
if (startBtn != null) startBtn.clicked += () => OnPlayButtonPressed();
75-
if (settingsBtn != null) settingsBtn.clicked += () => OnOptionsButtonPressed();
82+
if (settingsBtn != null) settingsBtn.clicked += () => OnOptionsButtonPressed();
7683
if (quitBtn != null) quitBtn.clicked += () => OnExitButtonPressed();
7784

7885
quitOverlay = root.Q<VisualElement>("quit-overlay");
@@ -122,7 +129,6 @@ private void InputHandler()
122129

123130
private void OnPlayButtonPressed()
124131
{
125-
// Load the main game scene
126132
CameraTransition(MenuState.MainMenu);
127133

128134
cinemachineCamera_A.Target.TrackingTarget = spaceShip.transform;
@@ -132,6 +138,8 @@ private void OnPlayButtonPressed()
132138
mainMenuContainer.style.display = DisplayStyle.None;
133139

134140
StartCoroutine(SpaceShipAnimation());
141+
142+
Invoke("GoToPlayScene", shipDuraction + 1);
135143
}
136144

137145
private void OnOptionsButtonPressed()
@@ -143,6 +151,11 @@ private void OnOptionsButtonPressed()
143151

144152
settingsOverlay.style.display = DisplayStyle.Flex;
145153
mainMenuContainer.style.display = DisplayStyle.None;
154+
155+
// Load current settings
156+
masterVolumeSlider.value = settings.masterVolume;
157+
musicVolumeSlider.value = settings.musicVolume;
158+
fullscreenToggle.value = settings.isFullscreen;
146159
}
147160

148161
private void OnExitButtonPressed()
@@ -188,7 +201,11 @@ private void ApplySettings()
188201
AudioListener.volume = masterVolume;
189202
Screen.fullScreen = isFullscreen;
190203

191-
Debug.Log("Settings applied: Master Volume = " + masterVolume + ", Fullscreen = " + isFullscreen);
204+
settings.masterVolume = masterVolume;
205+
settings.musicVolume = musicVolumeSlider.value;
206+
settings.isFullscreen = isFullscreen;
207+
208+
BackToMainMenu();
192209
}
193210

194211
private void BackToMainMenu()
@@ -215,6 +232,11 @@ private void OnApplicationQuit()
215232
Application.Quit();
216233
}
217234

235+
private void GoToPlayScene()
236+
{
237+
SceneManager.LoadScene("BluePlanet");
238+
}
239+
218240
private IEnumerator SpaceShipAnimation()
219241
{
220242
Vector3 initialPosition = spaceShip.transform.position;

Red Strike/Assets/UserChoices.choices

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)