void Update() { this.spectatorCanvas.enabled = Spectator.IsSpectating(); if (this.spectatorCanvas.enabled) { // update text based on spectated object string text = ""; var co = Spectator.GetSpectatingGameObject().GetComponent <ControllableObject> (); if (co != null) { var player = co.playerOwner; if (player != null) { text = player.playerName + " "; if (player.Team != "") { text += "(" + player.Team + ") "; } text += "<color=orange>[" + player.health + "]</color>"; } else { // Debug.LogWarning ("Spectated controllable object has no player owner"); } } this.spectatingObjectText.text = text; } }
void Start() { // add button handlers if (goPreviousButton != null) { goPreviousButton.onClick.AddListener(() => { Spectator.FindObjectForSpectating(-1); }); } if (goNextButton != null) { goNextButton.onClick.AddListener(() => { Spectator.FindObjectForSpectating(1); }); } }
// Update is called once per frame void Update() { if (null == Camera.main) { return; } if (null == Player.local) { return; } if (Player.local.GetControllingGameObject() == this.gameObject || Spectator.GetSpectatingGameObject() == this.gameObject) { this.UpdateCamera(); } }