@@ -21,15 +21,15 @@ public string Version
2121 get { return "v3.0" ; }
2222 }
2323
24- public const float MaxSize = 5f ;
24+ public const float MaxSize = 5.05f ;
2525 public const float StepSize = 0.05f ;
2626
27- public static GameObject SettingsObject ;
27+ public static GameObject SettingsObject { get ; private set ; }
2828
2929 public static float TimeScale
3030 {
3131 get { return _timeScale ; }
32- set
32+ private set
3333 {
3434 _timeScale = value ;
3535 if ( ! IsEqualToOne ( _timeScale ) )
@@ -92,23 +92,31 @@ private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
9292 {
9393 var resultsViewController =
9494 Resources . FindObjectsOfTypeAll < ResultsViewController > ( ) . FirstOrDefault ( ) ;
95- resultsViewController . continueButtonPressedEvent += ResultsViewControllerOnContinueButtonPressedEvent ;
95+ if ( resultsViewController != null )
96+ resultsViewController . continueButtonPressedEvent +=
97+ ResultsViewControllerOnContinueButtonPressedEvent ;
9698 }
99+
100+ if ( SettingsObject != null ) return ;
97101
98- if ( SettingsObject == null )
99- {
100- var volumeSettings = Resources . FindObjectsOfTypeAll < VolumeSettingsController > ( ) . FirstOrDefault ( ) ;
101- volumeSettings . gameObject . SetActive ( false ) ;
102- SettingsObject = Object . Instantiate ( volumeSettings . gameObject ) ;
103- SettingsObject . SetActive ( false ) ;
104- volumeSettings . gameObject . SetActive ( true ) ;
105- var volume = SettingsObject . GetComponent < VolumeSettingsController > ( ) ;
106- ReflectionUtil . CopyComponent ( volume , typeof ( IncDecSettingsController ) ,
107- typeof ( SpeedSettingsController ) , SettingsObject ) ;
108- Object . DestroyImmediate ( volume ) ;
109- SettingsObject . GetComponentInChildren < TMP_Text > ( ) . text = "SPEED" ;
110- Object . DontDestroyOnLoad ( SettingsObject ) ;
111- }
102+ var volumeSettings = Resources . FindObjectsOfTypeAll < VolumeSettingsController > ( ) . FirstOrDefault ( ) ;
103+
104+ if ( volumeSettings == null ) return ;
105+
106+ volumeSettings . gameObject . SetActive ( false ) ;
107+ SettingsObject = Object . Instantiate ( volumeSettings . gameObject ) ;
108+ SettingsObject . SetActive ( false ) ;
109+ volumeSettings . gameObject . SetActive ( true ) ;
110+
111+ if ( SettingsObject == null ) return ;
112+
113+ var volume = SettingsObject . GetComponent < VolumeSettingsController > ( ) ;
114+ ReflectionUtil . CopyComponent ( volume , typeof ( IncDecSettingsController ) ,
115+ typeof ( SpeedSettingsController ) , SettingsObject ) ;
116+ Object . DestroyImmediate ( volume ) ;
117+
118+ SettingsObject . GetComponentInChildren < TMP_Text > ( ) . text = "SPEED" ;
119+ Object . DontDestroyOnLoad ( SettingsObject ) ;
112120 }
113121 else
114122 {
@@ -153,11 +161,14 @@ private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
153161 TimeScale = Mathf . Clamp ( TimeScale , 1 , MaxSize ) ;
154162 }
155163
156- NoteHitPitchChanger . ReplacePrefab ( ) ;
164+ NoteCutSoundReplacer . ReplacePrefab ( ) ;
157165
158166 var canvas = Resources . FindObjectsOfTypeAll < HorizontalLayoutGroup > ( )
159167 . FirstOrDefault ( x => x . name == "Buttons" )
160- . transform . parent ;
168+ ? . transform . parent ;
169+
170+ if ( canvas == null ) return ;
171+
161172 _uiElementsCreator = canvas . gameObject . AddComponent < UIElementsCreator > ( ) ;
162173 _uiElementsCreator . ValueChangedEvent += UIElementsCreatorOnValueChangedEvent ;
163174 _uiElementsCreator . Init ( ) ;
0 commit comments