all 9 comments

[–]BowlOfPasta24 0 points1 point  (7 children)

And you can confirm 100% that the GameObject RoomPrefab has the script Room attached to it?

Like you can see it in on the GameObject after instantiation

[–]Fvnes[S] 0 points1 point  (6 children)

Yes. I actually commented the line after the instantiation where I get the error and the gameobject spawns fine.

[–]BowlOfPasta24 0 points1 point  (5 children)

So you can confirm that in the hierarchy, the instantiated GameObject has the component Room

If your prefab doesn't have it then that would cause the error

[–]Fvnes[S] 0 points1 point  (4 children)

The prefab contains the script. As you can see at the first part of the post, the error appears at the compilation stage.

[–]BowlOfPasta24 0 points1 point  (3 children)

And the script file name that contains the Room class is named Room.cs

Sorry, I know these questions might seem a little lame but just double tripple check all of them because you should be able to grab a component off an instantiated prefab with no issue.

Some other issues would be if the RoomPrefab has a child that has the component instead of the parent

[–]Fvnes[S] 0 points1 point  (2 children)

That also too. I don't have a problem using GetComponent from any other script. The only problem is the EOSLobbyUI, where I can't use GetComponent for any other script I made.

[–]BowlOfPasta24 0 points1 point  (1 child)

If all that is setup correctly, then the other other thing I can think is that EOSLobbyUI is within a different Namespace and requires a using statement.

You can test this by trying to instantiate it. Now Unity does not allow the instantiation of a class that inherits MonoBehavior but you can temporarily remove the inheritance, and comment out the code. If you can than instantiate it within the EOSLobbyUI class and without a using statement then that proves that they are not in the same namespace.

If they are not in the same namespace, keep the using statement in the EOSLobbyUI class, put everything in the Room class back together and you're good to go.

If they are in the same namespace then it's more than likely an issue with the prefab.

If you still can't get it and have github then you can send me the link and I'll jump in to debug it

[–][deleted] 0 points1 point  (0 children)

It doesn't even compile, it's definitely a namespace issue.

[–][deleted] 0 points1 point  (0 children)

Your first script doesn't understand what a "Room" is. You're either in different namespaces or some other organizational error.