the script don't inherit a native class that can manage a script unity

610 Views Asked by At

I'm a beginner programmer on c# and Unity. So I was making a grid system for my game and when I'm trying to add as a component every script in my unity project it prints this one error : "The script don't inherit a native class that can manage a script" I don't know what i need to do.Help me please if u can

//////////first script///////////////

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Gird1 : MonoBehaviour
{
    private int width;
    private int height;
    private int[,] gridArray;

    public Gird(int width, int height)
    {
        this.width = width;
        this.height = height;
        gridArray = new int[width, height];
        Debug.Log(width + " " + height);
      }
}

////////second script////////////////////

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Testing : MonoBehaviour
{

   private void Start()
   {
       Grid grid = new Grid(20, 10);
   }


   void Update()
   {

   }
}

image of grid

1

There are 1 best solutions below

1
Selzier On

Your first script is named "Gird" not "Grid".

Second Script:

public class Testing : MonoBehaviour
{
   public Gird1 gird1; // Assign in the inspector. We need an instance of Gird1

   private void Start()
   {
       if (gird1 == null) { // In case someone forgot to assign in the inspector
           gird1 = (Gird1)FindObjectOfType(typeof(Gird1)); // .. We'll search the scene
       }
       gird1.Gird(20,10); // Call the Gird() function on your gird1 instance
   }
}