Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Networking.Match;
- public class JoinRoom : MonoBehaviour {
- LobbyManager lobbyManager;
- public GameObject hostGamePrefab;
- public GameObject parentForHost;
- // Use this for initialization
- void Start () {
- lobbyManager = GameObject.FindGameObjectWithTag ("lobbyManager").GetComponent<LobbyManager> ();
- }
- // Update is called once per frame
- void Update () {
- }
- public void RefreshList(){
- if (lobbyManager == null) {
- lobbyManager = (LobbyManager)GameObject.FindGameObjectWithTag ("lobbyManager").GetComponent<LobbyManager> ();
- // this line prints every time, meaning my lobbyManager is not being set
- print ("lobby manager is null");
- // this line prints as well and points me to the object it is supposed to be referencing
- print (GameObject.FindGameObjectWithTag ("lobbyManager").GetComponent<LobbyManager> ());
- }
- if (lobbyManager.matchMaker == null) {
- lobbyManager.StartMatchMaker ();
- }
- lobbyManager.matchMaker.ListMatches (0, 20, "", true, 0, 0, OnMatchList);
- }
- private void OnMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matchList){
- print ("JoinRoom:: OnMatchList");
- if (!success) {
- print ("Please refresh the list");
- }
- foreach (MatchInfoSnapshot match in matchList) {
- GameObject listGO = Instantiate (hostGamePrefab);
- listGO.transform.SetParent (parentForHost.transform);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement