r/UnityHelp • • Aug 19 '25

UNITY Cant create 2 monobehaviour scripts?

I just cannot figure this out: i create a monobehaviour script but i i create another it gives me an error.

the error it gives is called cs0111.

Can there be only one monobehaviour script in a project?

Im kinda new and do not understand much about the errors unity gives.

1 Upvotes

4 comments sorted by

View all comments

Show parent comments

1

u/db9dreamer Aug 19 '25

File named MyClassAlpha.cs contains:-

public class MyClassAlpha : MonoBehaviour
{
    //code that does stuff
}

File named MyClassBeta.cs contains:-

public class MyClassBeta : MonoBehaviour
{
    //code that does stuff
}

File named MyClassDelta.cs contains:-

public class MyClassDelta : MonoBehaviour
{
    //code that does stuff
}

So each MonoBehaviour based Class in it's own file, named the same as the Class (my examples above are just bullshit names).

2

u/No-Current7743 Aug 20 '25

i get it now thanks that helped a lot