'The script doesn't interhit a native class that can manage a object. and I have ,,all compile errors have to be fix before entering play mode"

So, i was creating new script ChestManager (code here:

public class ChestManager : MonoBehaviour
{
    public PlayerController cont;

    public GameObject BookZeroPrefab;
    public GameObject BookOnePrefab;
    public GameObject BookTwoPrefab;


    void Start()
    {
        cont = FindObjectOfType<PlayerController>();
    }

    {
        if(col.gameObject.tag == "Player")
        {
            OpenChest();
        }
    }

    void OpenChest()
    {
        float radnom_health = Random.Range(0,30);

        cont.Heal(radnom_health);

        float random_chance = Random.Range(0,100);

        if(random_chance <= 75)
        {
            int chance1 = Random.Range(0,2);
            for(int i = 0; i < chance1; i++){
                float book = Random.Range(0,2);
                if(book == 0) Instantiate(BookZeroPrefab, transform.position, transform.rotation);
                if(book == 1) Instantiate(BookOnePrefab, transform.position, transform.rotation);
                if(book == 2) Instantiate(BookTwoPrefab, transform.position, transform.rotation);

            }
        }

        Destroy(gameObject);
    }
}

but when i try to attach this script, an error says

The script doesn't interhit a native class that can manage a script

and also when i try to enter play mode, next error says:

All compile errors have to be fix before entering play mode.

And now, all of the scripts, that was working goood, now says The script doesn't interhit a native class! Any suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source