Getting an error when I try to FindObjectsOfType. Any idea why?
“The type or namespace name ‘MusicPlayer’ could not be found”
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DoNotDestroy : MonoBehaviour
{
void Awake()
{
int numMusicPlayers = FindObjectsOfType<MusicPlayer>().Length;
print(numMusicPlayers);
DontDestroyOnLoad(gameObject);
}
}
MusicPlayer game object is in the scene.
Help!