Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class SaveInfo : MonoBehaviour {
- public GameObject serverInfoContent;
- public GameObject serverInfoPanelPrefab;
- public GameObject roomInformation;
- public GameObject serverInfoPanel;
- public ServerInfoPanel serverInfoPanelScript;
- void Start () {
- }
- void Update () {
- }
- private void OnReceivedRoomListUpdate () {
- PopulateServerList ();
- }
- public void PopulateServerList () {
- if (serverInfoContent.GetComponentInChildren<ServerInfoPanel>()) {
- foreach (ServerInfoPanel destroy in serverInfoContent.GetComponentsInChildren<ServerInfoPanel>()) {
- Destroy(destroy.gameObject);
- }
- }
- foreach (var room in PhotonNetwork.GetRoomList ()) {
- roomInformation = Instantiate (serverInfoPanelPrefab);
- serverInfoPanel = roomInformation;
- serverInfoPanelScript = serverInfoPanel.GetComponent <ServerInfoPanel> ();
- roomInformation.transform.SetParent (serverInfoContent.transform, false);
- ServerInfoPanel panel = roomInformation.GetComponent<ServerInfoPanel>();
- serverInfoPanelScript.serverName.text = room.name;
- serverInfoPanelScript.serverPlayers.text = string.Format("{0}/{1}", room.playerCount, room.maxPlayers);
- serverInfoPanelScript.joinButton.onClick.AddListener (() => PhotonNetwork.JoinRoom(room.name));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement