Home > database >  UI Scene Object Reference issue. Unity
UI Scene Object Reference issue. Unity

Time:10-02

I am trying to make a respawn UI, and my player is a prefab. The problem is I need to get a reference of the UI object, but I can't because, you can't reference a scene object in a prefab. I tried other people's advice like make the object you want to reference a prefab, but I can't do that because the object is a UI. Is there any other way?

CodePudding user response:

There are many ways to do that, Here is a simple one:

  • Create a Monobehavior Manager script
  • Pass all the UI references in it
  • Store the Instantiated player object in a variable
  • Use getcomponent<> to get players' script
  • Pass the UI reference here.
  • Related