File tree 1 file changed +21
-16
lines changed
1 file changed +21
-16
lines changed Original file line number Diff line number Diff line change @@ -12,24 +12,35 @@ public class GameManager : MonoBehaviour
12
12
[ SerializeField ] private GameObject playButton ;
13
13
[ SerializeField ] private GameObject gameOver ;
14
14
15
- private int score ;
16
- public int Score => score ;
15
+ public int score { get ; private set ; }
17
16
18
17
private void Awake ( )
19
18
{
20
- if ( Instance != null )
21
- {
19
+ if ( Instance != null ) {
22
20
DestroyImmediate ( gameObject ) ;
23
- }
24
- else
25
- {
21
+ } else {
26
22
Instance = this ;
27
- Application . targetFrameRate = 60 ;
28
- DontDestroyOnLoad ( gameObject ) ;
29
- Pause ( ) ;
30
23
}
31
24
}
32
25
26
+ private void OnDestroy ( )
27
+ {
28
+ if ( Instance == this ) {
29
+ Instance = null ;
30
+ }
31
+ }
32
+
33
+ private void Start ( )
34
+ {
35
+ Pause ( ) ;
36
+ }
37
+
38
+ public void Pause ( )
39
+ {
40
+ Time . timeScale = 0f ;
41
+ player . enabled = false ;
42
+ }
43
+
33
44
public void Play ( )
34
45
{
35
46
score = 0 ;
@@ -56,12 +67,6 @@ public void GameOver()
56
67
Pause ( ) ;
57
68
}
58
69
59
- public void Pause ( )
60
- {
61
- Time . timeScale = 0f ;
62
- player . enabled = false ;
63
- }
64
-
65
70
public void IncreaseScore ( )
66
71
{
67
72
score ++ ;
You can’t perform that action at this time.
0 commit comments