Soy un programador principiante en C# y Unity. Así que estaba creando un sistema de cuadrícula para mi juego y cuando intento agregar como componente cada secuencia de comandos en mi proyecto de Unity, muestra este error: "La secuencia de comandos no hereda una clase nativa que pueda administrar una secuencia de comandos". no se que debo hacer ayudenme por favor si pueden
//////////primer guión///////////////
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); } }
////////segundo guion////////////////////
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Testing : MonoBehaviour { private void Start() { Grid grid = new Grid(20, 10); } void Update() { } }
Su primer script se llama "Gird" no "Grid".
Segundo guión:
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 } }