Levelauswahl.cs 1.14 KB
Newer Older
Isa's avatar
Isa committed
1
2
3
4
5
6
7
8
9
10
11
12
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

namespace LevelauswahlScript
{
	public class Levelauswahl : MonoBehaviour
	{
		public static Levelauswahl la;
		public GameObject Auswahl;
Isa's avatar
Isa committed
13
		public EventSystem _myEventSystem;
Isa's avatar
Isa committed
14
		public Button firstSelect;
Isa's avatar
Isa committed
15
16

		private SavePoint[] savePoints;
Isa's avatar
Isa committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
		// Start is called before the first frame update
		void Start()
		{
			la = this;
		}

		private void Update()
		{
			if (Input.GetButtonDown("Cancel") && Auswahl.activeSelf == true)
			{
				Resume();
			}
		}

		IEnumerator highlightBtn()
		{
			_myEventSystem.SetSelectedGameObject(null);
			yield return null;
			_myEventSystem.firstSelectedGameObject = firstSelect.gameObject;
			_myEventSystem.SetSelectedGameObject(_myEventSystem.firstSelectedGameObject);
		}

		// Update is called once per frame
		public void GetLevelauswahl()
		{
			Auswahl.SetActive(true);
			StartCoroutine("highlightBtn");
			Time.timeScale = 0f;
		}

		public void Resume()
		{
			Auswahl.SetActive(false);
			Time.timeScale = 1f;
		}

		public bool auswahlIsActive()
		{
			return Auswahl.activeSelf;
		}
	}
}