fixes
This commit is contained in:
parent
13100a8399
commit
8dbd9243e1
|
@ -2,7 +2,6 @@ using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Unity.VisualScripting;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class AudioManager : MonoBehaviour
|
public class AudioManager : MonoBehaviour
|
||||||
|
@ -11,28 +10,23 @@ public class AudioManager : MonoBehaviour
|
||||||
public AudioLibraryObject audioLibrary;
|
public AudioLibraryObject audioLibrary;
|
||||||
|
|
||||||
|
|
||||||
private void OnEnable()
|
private void Awake()
|
||||||
{
|
{
|
||||||
if (Instance is null)
|
if (Instance != null)
|
||||||
{
|
{
|
||||||
Instance = this;
|
Destroy(this);
|
||||||
// TODO: manager itself should not handle this
|
// TODO: manager itself should not handle this
|
||||||
// DontDestroyOnLoad(this);
|
// DontDestroyOnLoad(this);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
Instance = this;
|
||||||
{
|
|
||||||
Destroy(Instance);
|
|
||||||
Instance = this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDisable()
|
|
||||||
{
|
|
||||||
Instance = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AudioClip FindAudioClip(string nameOfClip)
|
public static AudioClip FindAudioClip(string nameOfClip)
|
||||||
{
|
{
|
||||||
|
Debug.Log(nameOfClip);
|
||||||
|
Debug.Log(Instance);
|
||||||
|
Debug.Log(Instance.audioLibrary);
|
||||||
return Instance.audioLibrary.Clips.First(x => x.name == nameOfClip);
|
return Instance.audioLibrary.Clips.First(x => x.name == nameOfClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,13 @@ public class GameManager : MonoBehaviour
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
if (Instance != this)
|
if (Instance != null)
|
||||||
Destroy(Instance);
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Instance = this;
|
Instance = this;
|
||||||
health = startHealth;
|
health = startHealth;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,12 @@ public class MusicManager : MonoBehaviour
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
|
if (Instance != null)
|
||||||
|
{
|
||||||
|
Destroy(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Instance = this;
|
||||||
sources = new AudioSource[intensities.Length];
|
sources = new AudioSource[intensities.Length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue