示例#1
0
        private void Awake()
        {
            // if the singleton hasn't been initialized yet
            if (instance != null && instance != this)
            {
                Destroy(this.gameObject);
            }

            instance = this;
            DontDestroyOnLoad(this.gameObject);
        }
示例#2
0
        // Start is called before the first frame update
        void Start()
        {
            GameObject _serverObject = new GameObject();

            _serverObject.name = "Server";
            Server             = _serverObject.AddComponent <ServerBehaviour>() as ServerBehaviour;
            Server.Lobby       = this;

            LobbyUI = Instantiate(Resources.Load("HostLobby") as GameObject);
            Button b = LobbyUI.transform.Find("StartGame").GetComponent <Button>();

            b.onClick.AddListener(delegate() { Server.StartGame(); });
        }