Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2469d67

Browse files
Added functionality to slider
added the sliders for sensitivity and for music volume
1 parent a3b10e0 commit 2469d67

File tree

2 files changed

+1292
-2600
lines changed

2 files changed

+1292
-2600
lines changed

‎Native/Assets/Menus/MenuManager.cs

Lines changed: 196 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ public class MenuManager : MonoBehaviour
5757
[Header("########################################")]
5858
[Header("General Settings")]
5959
public GameObject settingsGeneralOptions;
60+
public GameObject[] generalSettingsButtons;
61+
public int curGeneralSetting;
6062

6163
[Header("########################################")]
6264
[Header("Sound Settings")]
6365
public GameObject settingsSoundOptions;
66+
public GameObject[] soundSettingsButtons;
67+
public int curSoundSetting;
6468

6569
[Header("########################################")]
6670
[Header("Controls Settings")]
@@ -130,156 +134,238 @@ void Update()
130134
{
131135
if (mainScreen.activeInHierarchy)
132136
{
133-
if (Up.action.WasPressedThisFrame() && curSelected > 0)
134-
curSelected--;
135-
else if (Down.action.WasPressedThisFrame() && curSelected < buttons.Length-1)
136-
curSelected++;
137-
EventSystem.current.SetSelectedGameObject(null);
138-
EventSystem.current.SetSelectedGameObject(buttons[curSelected]);
137+
inMainScreenMenu();
139138
}
140139
else if (levelSelectScreen.activeInHierarchy && !prematureUpdateCall)
141140
{
142-
if (Left.action.WasPressedThisFrame() && curLevel > 0)
143-
{
144-
curLevel--;
145-
sorter.transform.position = new Vector3(sorter.transform.position.x + moveAmmount,
146-
sorter.transform.position.y,
147-
sorter.transform.position.z);
148-
}
149-
else if (Right.action.WasPressedThisFrame() && curLevel < sorter.transform.childCount - 1)
150-
{
151-
curLevel++;
152-
sorter.transform.position = new Vector3(sorter.transform.position.x - moveAmmount,
153-
sorter.transform.position.y,
154-
sorter.transform.position.z);
155-
}
156-
157-
if (B.action.WasPressedThisFrame())
158-
{
159-
levelSelectScreen.SetActive(false);
160-
mainScreen.SetActive(true);
161-
}
162-
else if (A.action.WasPressedThisFrame())
163-
{
164-
levelSelectScreen.SetActive(false);
165-
levelInfo.SetActive(true);
166-
level = currentLevelSceneIndex[curLevel];
167-
}
141+
inLevelSelectMenu();
168142
}
169143
else if (levelInfo.activeInHierarchy)
170144
{
171-
if (firstTime)
172-
{
173-
// load all of the basic elements in (the level info)
174-
levelName.text = "Level " + (curLevel + 1).ToString();
175-
levelInfoText.text = "THIS IS A PLACE HOLDER FOR THE ACTUAL DESCRIPTION\n" + (curLevel + 1).ToString();
176-
//levelImage.sprite = Sprite;
177-
firstTime = false;
178-
}
179-
if (B.action.WasPressedThisFrame())
180-
{
181-
levelInfo.SetActive(false);
182-
levelSelectScreen.SetActive(true);
183-
firstTime = true;
184-
}
185-
else if (A.action.WasPressedThisFrame())
186-
{
187-
SceneLoadingManager.instance.loadscene(level);
188-
Debug.Log("LOAD LEVEL: " + (level).ToString());
189-
}
145+
inLevelInfoMenu();
190146
}
191147
else if (settingsScreen.activeInHierarchy && !prematureUpdateCall)
192148
{
193-
if (inSettings)
149+
inSettingsMenu();
150+
}
151+
else if (creditsUI.activeInHierarchy && !prematureUpdateCall)
152+
{
153+
inCreditsMenu();
154+
}
155+
prematureUpdateCall = false;
156+
}
157+
158+
public void inMainScreenMenu()
159+
{
160+
if (Up.action.WasPressedThisFrame() && curSelected > 0)
161+
curSelected--;
162+
else if (Down.action.WasPressedThisFrame() && curSelected < buttons.Length - 1)
163+
curSelected++;
164+
EventSystem.current.SetSelectedGameObject(null);
165+
EventSystem.current.SetSelectedGameObject(buttons[curSelected]);
166+
}
167+
168+
public void inLevelSelectMenu()
169+
{
170+
if (Left.action.WasPressedThisFrame() && curLevel > 0)
171+
{
172+
curLevel--;
173+
sorter.transform.position = new Vector3(sorter.transform.position.x + moveAmmount,
174+
sorter.transform.position.y,
175+
sorter.transform.position.z);
176+
}
177+
else if (Right.action.WasPressedThisFrame() && curLevel < sorter.transform.childCount - 1)
178+
{
179+
curLevel++;
180+
sorter.transform.position = new Vector3(sorter.transform.position.x - moveAmmount,
181+
sorter.transform.position.y,
182+
sorter.transform.position.z);
183+
}
184+
185+
if (B.action.WasPressedThisFrame())
186+
{
187+
levelSelectScreen.SetActive(false);
188+
mainScreen.SetActive(true);
189+
}
190+
else if (A.action.WasPressedThisFrame())
191+
{
192+
levelSelectScreen.SetActive(false);
193+
levelInfo.SetActive(true);
194+
level = currentLevelSceneIndex[curLevel];
195+
}
196+
}
197+
public void inLevelInfoMenu()
198+
{
199+
if (firstTime)
200+
{
201+
// load all of the basic elements in (the level info)
202+
levelName.text = "Level " + (curLevel + 1).ToString();
203+
levelInfoText.text = "THIS IS A PLACE HOLDER FOR THE ACTUAL DESCRIPTION\n" + (curLevel + 1).ToString();
204+
//levelImage.sprite = Sprite;
205+
firstTime = false;
206+
}
207+
if (B.action.WasPressedThisFrame())
208+
{
209+
levelInfo.SetActive(false);
210+
levelSelectScreen.SetActive(true);
211+
firstTime = true;
212+
}
213+
else if (A.action.WasPressedThisFrame())
214+
{
215+
SceneLoadingManager.instance.loadscene(level);
216+
Debug.Log("LOAD LEVEL: " + (level).ToString());
217+
}
218+
}
219+
public void inSettingsMenu()
220+
{
221+
if (inSettings)
222+
{
223+
if (settingsGeneralOptions.activeInHierarchy)
194224
{
195-
if (settingsGeneralOptions.activeInHierarchy)
196-
{
225+
if (Up.action.WasPressedThisFrame() && curGeneralSetting > 0)
226+
curGeneralSetting--;
227+
else if (Down.action.WasPressedThisFrame() && curGeneralSetting < generalSettingsButtons.Length - 1)
228+
curGeneralSetting++;
197229

198-
}
199-
else if (settingsSoundOptions.activeInHierarchy)
200-
{
230+
EventSystem.current.SetSelectedGameObject(null);
231+
EventSystem.current.SetSelectedGameObject(generalSettingsButtons[curGeneralSetting]);
201232

202-
}
203-
else if (settingsControlOptions.activeInHierarchy)
233+
if (Right.action.IsPressed())
204234
{
205-
if (Up.action.WasPressedThisFrame() && (curControlSetting == 1 ||
206-
curControlSetting == 3))
207-
curControlSetting--;
208-
else if (Down.action.WasPressedThisFrame() && (curControlSetting == 0 ||
209-
curControlSetting == 2))
210-
curControlSetting++;
211-
else if (Right.action.WasPressedThisFrame() && (curControlSetting == 0 ||
212-
curControlSetting == 1))
213-
curControlSetting += 2;
214-
else if (Left.action.WasPressedThisFrame() && (curControlSetting == 2 ||
215-
curControlSetting == 3))
216-
curControlSetting -= 2;
217-
218-
EventSystem.current.SetSelectedGameObject(null);
219-
EventSystem.current.SetSelectedGameObject(controlSettingButtons[curControlSetting]);
220-
221-
if (A.action.WasPressedThisFrame())
235+
Slider slider = EventSystem.current.currentSelectedGameObject.GetComponent<Slider>();
236+
if (slider != null)
222237
{
223-
if (curControlSetting==0)
238+
if (slider.value<slider.maxValue)
224239
{
225-
// swap the input of the movement and aim
226-
Debug.Log("Movement & Aim");
240+
slider.value += 0.005f;
227241
}
228-
else if (curControlSetting == 1)
229-
{
230-
// call the record new input for the shoot function
231-
Debug.Log("Shoot");
232-
}
233-
else if (curControlSetting == 2)
234-
{
235-
// call the record new input for the pickup function
236-
Debug.Log("Pickup");
237-
}
238-
else if (curControlSetting == 3)
242+
}
243+
}
244+
else if (Left.action.IsPressed())
245+
{
246+
Slider slider = EventSystem.current.currentSelectedGameObject.GetComponent<Slider>();
247+
if (slider != null)
248+
{
249+
if (slider.value > slider.minValue)
239250
{
240-
// call the record new input for the dodge function
241-
Debug.Log("Dodge");
251+
slider.value -= 0.005f;
242252
}
243-
else if (curControlSetting == 4)
253+
}
254+
}
255+
}
256+
else if (settingsSoundOptions.activeInHierarchy)
257+
{
258+
if (Up.action.WasPressedThisFrame() && curSoundSetting > 0)
259+
curSoundSetting--;
260+
else if (Down.action.WasPressedThisFrame() && curSoundSetting < soundSettingsButtons.Length-1)
261+
curSoundSetting++;
262+
263+
EventSystem.current.SetSelectedGameObject(null);
264+
EventSystem.current.SetSelectedGameObject(soundSettingsButtons[curSoundSetting]);
265+
266+
if (Right.action.IsPressed())
267+
{
268+
Slider slider = EventSystem.current.currentSelectedGameObject.GetComponent<Slider>();
269+
if (slider != null)
270+
{
271+
if (slider.value < slider.maxValue)
244272
{
245-
// call the record new input for the throw function
246-
Debug.Log("Throw");
273+
slider.value += 0.005f;
247274
}
248275
}
249276
}
250-
251-
if (B.action.WasPressedThisFrame())
277+
else if (Left.action.IsPressed())
252278
{
253-
inSettings = false;
279+
Slider slider = EventSystem.current.currentSelectedGameObject.GetComponent<Slider>();
280+
if (slider != null)
281+
{
282+
if (slider.value > slider.minValue)
283+
{
284+
slider.value -= 0.005f;
285+
}
286+
}
254287
}
255288
}
256-
else
289+
elseif(settingsControlOptions.activeInHierarchy)
257290
{
258-
if (Up.action.WasPressedThisFrame() && settingsCurSelected > 0)
259-
settingsCurSelected--;
260-
else if (Down.action.WasPressedThisFrame() && settingsCurSelected < settingsButtons.Length - 1)
261-
settingsCurSelected++;
291+
if (Up.action.WasPressedThisFrame() && (curControlSetting == 1 ||
292+
curControlSetting == 3))
293+
curControlSetting--;
294+
else if (Down.action.WasPressedThisFrame() && (curControlSetting == 0 ||
295+
curControlSetting == 2))
296+
curControlSetting++;
297+
else if (Right.action.WasPressedThisFrame() && (curControlSetting == 0 ||
298+
curControlSetting == 1))
299+
curControlSetting += 2;
300+
else if (Left.action.WasPressedThisFrame() && (curControlSetting == 2 ||
301+
curControlSetting == 3))
302+
curControlSetting -= 2;
303+
262304
EventSystem.current.SetSelectedGameObject(null);
263-
EventSystem.current.SetSelectedGameObject(settingsButtons[settingsCurSelected]);
305+
EventSystem.current.SetSelectedGameObject(controlSettingButtons[curControlSetting]);
264306

265-
if (B.action.WasPressedThisFrame())
307+
if (A.action.WasPressedThisFrame())
266308
{
267-
settingsScreen.SetActive(false);
268-
mainScreen.SetActive(true);
309+
if (curControlSetting == 0)
310+
{
311+
// swap the input of the movement and aim
312+
Debug.Log("Movement & Aim");
313+
}
314+
else if (curControlSetting == 1)
315+
{
316+
// call the record new input for the shoot function
317+
Debug.Log("Shoot");
318+
}
319+
else if (curControlSetting == 2)
320+
{
321+
// call the record new input for the pickup function
322+
Debug.Log("Pickup");
323+
}
324+
else if (curControlSetting == 3)
325+
{
326+
// call the record new input for the dodge function
327+
Debug.Log("Dodge");
328+
}
329+
else if (curControlSetting == 4)
330+
{
331+
// call the record new input for the throw function
332+
Debug.Log("Throw");
333+
}
269334
}
270335
}
336+
337+
if (B.action.WasPressedThisFrame())
338+
{
339+
inSettings = false;
340+
}
271341
}
272-
elseif(creditsUI.activeInHierarchy&&!prematureUpdateCall)
342+
else
273343
{
344+
if (Up.action.WasPressedThisFrame() && settingsCurSelected > 0)
345+
settingsCurSelected--;
346+
else if (Down.action.WasPressedThisFrame() && settingsCurSelected < settingsButtons.Length - 1)
347+
settingsCurSelected++;
348+
EventSystem.current.SetSelectedGameObject(null);
349+
EventSystem.current.SetSelectedGameObject(settingsButtons[settingsCurSelected]);
350+
274351
if (B.action.WasPressedThisFrame())
275352
{
276-
creditsUI.SetActive(false);
353+
settingsScreen.SetActive(false);
277354
mainScreen.SetActive(true);
278355
}
279356
}
280-
prematureUpdateCall = false;
281357
}
282358

359+
public void inCreditsMenu()
360+
{
361+
if (B.action.WasPressedThisFrame())
362+
{
363+
creditsUI.SetActive(false);
364+
mainScreen.SetActive(true);
365+
}
366+
}
367+
368+
283369
public void SettingsGeneralPressed()
284370
{
285371
settingsGeneralOptions.SetActive(true);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /