Using Unity 5.1. I am creating a network (multiplayer) instantiated player object that has four cameras the player can choose from (forward, back, left, right). I also have a GUI HUD with a Text object names “Camera Label” for displaying the name of the currently active camera. The problem is getting a reference to Camera Label from the script that controls the camera switching (attached to the player prefab). For instance, if I do the following . . .
Text cameraLabel = GameObject.Find ("Canvas/Camera Label");
. . . I get the following error:
Assets/Scripts/CameraControl.cs(22,25): error CS0029: Cannot implicitly convert type `UnityEngine.GameObject' to `UnityEngine.UI.Text'
Looks like UI objects don’t inherit from GameObject. Any suggestions here? How can I get a reference to a Text object at runtime? (Yes, I know that in normal circumstances, I could make the Text variable public and then link it to Camera Label in the inspector. But remember, this is a network-instantiated prefab, so the link needs to happen in the Start() function. I can’t rely on public variables.)
Thanks for any help.