How do you set UI game elements for instantiated objects?

I’m making an RTS game, and had been following a tutorial by Nix on youtube to learn how to do everything. I created the canvas, with all the elements in place and it looked great, and worked great…for the single example unit I’d put into the scene world. Nix had me drop all those UI elements into public variables on the unit and it all worked fine, but then none of that translated to the prefab, so any instantiated units had nothing, so I tried making a UI holder script for all those elements, dragging them onto that (permanent) unit in the inspector and then make Instances of each one in each unit, but that doesn’t seem to be working either. Any help would be appreciated!!

Hello, @aetherfang_unity!

I suggest you to create singleton UI manager, where you will assign all needed UI prefabs and public variables that is used by each unit. Also you will need to add static func which will return UI manager instance.

Then inside your unit script in Awake you can “read” your UI manager by typing ManagerUI.GetInstance().PrefabCursor (its example to access field PrefabCursor from UI manager script).
No need to assign same stuff for each unit! Your units will read it from one place!

then inside unit script you will need to instantiate UI element by prefab, assign its parent to Canvas, and probably done!