I am trying to get all of the GameObjects with the tag of Player
but it comes up with the error "Cannot implicitly convert type int to UnityEngine.GameObject[]". My code is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
public class mymanager : MonoBehaviour
{
GameObject[] amount;
public GameObject winPanel;
void Start()
{
winPanel.SetActive(false);
}
// Update is called once per frame
void Update()
{
amount = GameObject.FindGameObjectsWithTag("Player").Length;
if(amount <= 1)
{
winPanel.SetActive(true);
}
else
{
winPanel.SetActive(false);
}
}
public void OnClickJoinLobby()
{
PhotonNetwork.LoadLevel("Lobby");
}
}
I wanted to count the amount of players and open a UI panel if there was a maximum of 1 player left.