Advertisement
Munchy2007

PunTutPart4_7

Sep 9th, 2016
7,839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5. namespace PUNTutorial
  6. {
  7.     public class MainMenu : Photon.PunBehaviour
  8.     {
  9.         static MainMenu instance;
  10.         GameObject ui;
  11.         Button joinGameButton;
  12.  
  13.         void Awake()
  14.         {
  15.             if (instance != null)
  16.             {
  17.                 DestroyImmediate(gameObject);
  18.                 return;
  19.             }
  20.             instance = this;
  21.  
  22.             ui = transform.FindAnyChild<Transform>("UI").gameObject;
  23.             joinGameButton = transform.FindAnyChild<Button>("JoinGameButton");
  24.  
  25.             joinGameButton.interactable = false;
  26.             ui.SetActive(true);
  27.         }
  28.  
  29.         public override void OnConnectedToMaster()
  30.         {
  31.             joinGameButton.interactable = true;
  32.         }
  33.  
  34.         void OnLevelWasLoaded(int level)
  35.         {
  36.             ui.SetActive(!PhotonNetwork.inRoom);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement