I keep getting the ‘the script don’t inherit a ntive class that can manage a script’ when I drag my script to an object
The code is here
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LevelController : MonoBehaviour
{
Monster[ ] monsters;
[SerializeField] string nextLevelName;
void OnEnable()
{
monsters = FindObjectsOfType();
}
// Update is called once per frame
void Update()
{
if (MonstersAreAllDead())
GoToNextLevel();
}
void GoToNextLevel()
{
Debug.Log("Go to Level " + nextLevelName);
}
bool MonstersAreAllDead()
{
foreach (var monster in monsters)
{
if (monster.gameObject.activeSelf)
return false;
}
return true;
}
}