I’m researching random level generation in Unity for a school project and I decided to use a tutorial from a youtuber named Six Dot Studios. In the (Procedural Generation in Unity (Tutorial) - YouTube) description he linked his project, and I decided to check it out, but it doesn’t work.
His “Room” script doesn’t derive from MonoBehaviour and adding MonoBehaviour doesn’t seem to make it work either, returning this error:
“You are trying to create a MonoBehaviour using the ‘new’ keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all UnityEngine.MonoBehaviour:.ctor() Room:.ctor(Vector2, Int32) (at Assets/Generation scripts/Room.cs:10) LevelGeneration:CreateRooms() (at Assets/Generation scripts/LevelGeneration.cs:56) LevelGeneration:Start() (at Assets/Generation scripts/LevelGeneration.cs:23)”
I can add more info if needed and the scripts can all be downloaded in the video desc, but my question is as follows
TL;DR: Is it possible to create a secondary, non-MonoBehaviour C# script and then add it to a GameObject through a Primay C# one?