void Start() { GameObject lobbyCanvasObj = MainCanvasManager.Instance.LobbyCanvas.gameObject; if (lobbyCanvasObj == null) { return; } LobbyCanvas lobbyCanvas = lobbyCanvasObj.GetComponent <LobbyCanvas>(); Button button = GetComponent <Button>(); button.onClick.AddListener(() => lobbyCanvas.OnClick_JoinRoom(RoomNameText.text)); }