i am working on a game where on start everything is instantiated.
one of my objects is a slider should be connected to a script on one of the objects.
on start i want to place the slider from the Main Camera(Clone) into the Slider slider of the script of the game object which requires the sliders use.
also i need to make the slider function access this script. i need to set the game object in the slider and choose the function. which i do not know how to do through code…
i know how to do this if everything is already in the scene but they are being instantiated instead so the values are null…
ive been trying allot to get the slider… its just not working… i have done it exactly as you wrote but it is not filling Slider slider…
the canvas which holds the slider is a child of the mainCamera… does that make a difference?
i wrote the code: i was able to retrieve the mainCamera GameObject, then in a different variable Slider slider i wrote:
slider = mainCamera.GetComponent();