internal void Awake() { // Heavy handed, but reset the nearby connections state. PlayGamesPlatform.InitializeNearby((client) => { Debug.Log("Nearby connections initialized"); client.StopAllConnections(); }); // initialize saved preferences. string defaultRoomName = PlayerPrefs.GetString(RoomNameKey); if (defaultRoomName != null && roomNameField != null) { roomNameField.text = defaultRoomName; } string defaultPlayerName = PlayerPrefs.GetString(PlayerNameKey); if (defaultRoomName != null && playerNameField != null) { playerNameField.text = defaultPlayerName; } int charIndex = PlayerPrefs.GetInt(AvatarIndexKey); Toggle[] chars = charGroup.GetComponentsInChildren <Toggle>(); for (int i = 0; i < chars.Length; i++) { chars[i].isOn = i == charIndex; } discoveredRooms = new Dictionary <string, GameObject>(); }
private void Awake() { PlayGamesPlatform.InitializeNearby((client) => { Debug.Log("Nearby connections initialized"); }); }
void InitNearby() { Debug.Log("***Initializing nearby connections …"); PlayGamesPlatform.InitializeNearby((client) => { Debug.Log("***Nearby connections initialized: client=" + client); StartNearbyBroadcast(); StartNearbyDiscovery(); }); }
public void onCreateRoom() { myEndpointId = UnityEngine.Random.Range(1000, 10000).ToString(); myName = UnityEngine.Random.Range(1000, 10000).ToString(); NearbyPlayer nearbyPlayer = new NearbyPlayer(SystemInfo.deviceUniqueIdentifier, myEndpointId, myName); globalNearbyPlayer = nearbyPlayer; NearbyRoom.StopAll(); PlayGamesPlatform.InitializeNearby((client) => { Debug.Log("Nearby connections initialized"); }); NearbyRoom nearbyRoom = new NearbyRoom("Most Popular Room!!"); nearbyRoom.AutoJoin = true; nearbyRoom.AlwaysOpen = true; isClient = false; nearbyRoom.OpenRoom(); //List<string> appIdentifiers = new List<string>(); //appIdentifiers.Add(PlayGamesPlatform.Nearby.GetAppBundleId()); //PlayGamesPlatform.Nearby.StartAdvertising( // "Awesome Game Host", // User-friendly name // appIdentifiers, // App bundle Id for this game // TimeSpan.FromSeconds(0),// 0 = advertise forever // (AdvertisingResult result) => // { // Debug.Log("OnAdvertisingResult: " + result); // }, // (ConnectionRequest request) => // { // Debug.Log("Received connection request: " + // request.RemoteEndpoint.ServiceId + " " + // request.RemoteEndpoint.EndpointId + " " + // request.RemoteEndpoint.Name); // } // ); }
public void Start() { PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder() // registers a callback to handle game invitations. .Build(); PlayGamesPlatform.InitializeInstance(config); // recommended for debugging: PlayGamesPlatform.DebugLogEnabled = true; PlayGamesPlatform.Activate(); PlayGamesPlatform.InitializeNearby((client) => { Debug.Log("Nearby connections initialized"); }); Dictionary <string, string> dic = new Dictionary <string, string> { { "EndPoint", PlayGamesPlatform.Nearby.LocalEndpointId() }, { "Name", PlayerPrefs.GetString("myName") }, { "Avatar", PlayerPrefs.GetString("myAvatar") } }; player.Add(dic); }
private void Start() { if (!Social.localUser.authenticated) { PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder() .EnableSavedGames() .Build(); PlayGamesPlatform.InitializeInstance(config); //PlayGamesPlatform.DebugLogEnabled = true; PlayGamesPlatform.Activate(); Social.localUser.Authenticate((bool success) => { if (success) { PlayGamesPlatform.InitializeNearby((client) => { nearbyInitialized = true; }); if (SceneManager.GetActiveScene().buildIndex == 0) { SceneManager.LoadScene(1); } } else { nearbyInitialized = false; signInOverride = true; if (SceneManager.GetActiveScene().buildIndex == 0) { SceneManager.LoadScene(1); } //TODO: warn user they are not logged in } }); } }