'Can't add generic script to GameObject Unity
My script is called Grid and when i try and drag it into a game object it says "cant add script as script class can't be found. Make sure that there are no compile errors and that the file name and class name match." what should i do, because the problem isn't the name i know thats different its to do with the arrows because they invalid data types when naming.
Solution 1:[1]
In Unity for a Script/Class to be added to a GameObject, your class needs to inherit MonoBehaviour. Like this:
public class Grid<TGridObjects>:MonoBehaviour
If you just want to execute functions in your Script without making it MonoBehaviour, you can call from another MonoBehaviour
Grid<sth> myVar = new Grid<sth>();
Also Note that the Filename "Grid.cs" needs to correspond to your classname Grid if you are using MonoBehaviours.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
