Hello, i want to create my own class of cell, for example.
So i have a prefab “Cell”.
In MainScript, that is attached to Empty game object i want to create array of this class.
So cell class:
`
public class Cell : MonoBehaviour {
GameObject CellSprite;
public Cell()
{
Instantiate(CellSprite, new Vector3(0, 0, 0), Quaternion.identity);
}
}
`
But the problem is, that i cant use “new” keyword in MainScript to create Cells, because of deriving from monobehaviour.
if i not derive from monobehaviour, i cant call Instantiate() in Cell;
So i want to create custom Class “Cell”, that would be encapsulating all logic for it.
i understand, that i can create array of GameObject`s in MainScript and call instantiate there, but i dont want. So what is the solution for this? Thanks)