void DidConnectToRoom(Realtime room) { if (!gameObject.activeInHierarchy || !enabled) { return; } // Create avatar if (_localAvatarPrefab == null) { Debug.LogError("Realtime Avatars local avatar prefab is null. Bailing."); return; } GameObject avatarGameObject = Realtime.Instantiate(_localAvatarPrefab.name, true, true, true, _realtime); if (avatarGameObject == null) { Debug.LogError("RealtimeAvatarManager: Failed to instantiate RealtimeAvatar prefab."); return; } localAvatar = avatarGameObject.GetComponent <RealtimeAvatar>(); if (avatarGameObject == null) { Debug.LogError("RealtimeAvatarManager: Successfully instantiated avatar prefab, but could not find the RealtimeAvatar component."); return; } localAvatar.localPlayer = _localPlayer; localAvatar.deviceType = GetRealtimeAvatarDeviceTypeForLocalPlayer(); }
public void _UnregisterAvatar(RealtimeAvatar avatar) { bool isLocalAvatar = false; List <KeyValuePair <int, RealtimeAvatar> > matchingAvatars = avatars.Where(keyValuePair => keyValuePair.Value == avatar).ToList(); foreach (KeyValuePair <int, RealtimeAvatar> matchingAvatar in matchingAvatars) { int avatarClientID = matchingAvatar.Key; avatars.Remove(avatarClientID); isLocalAvatar = isLocalAvatar || avatarClientID == _realtime.clientID; } if (isLocalAvatar || _realtime.clientID == -1) { if (localOfflineAvatar != null) { localOfflineAvatar.SetActive(true); } } // Fire event if (avatarDestroyed != null) { try { avatarDestroyed(this, avatar, isLocalAvatar); } catch (System.Exception exception) { Debug.LogException(exception); } } }
public void _RegisterAvatar(int clientID, RealtimeAvatar avatar) { if (avatars.ContainsKey(clientID)) { Debug.LogError("RealtimeAvatar registered more than once for the same clientID (" + clientID + "). This is a bug!"); } avatars[clientID] = avatar; }
public void _UnregisterAvatar(RealtimeAvatar avatar) { List <KeyValuePair <int, RealtimeAvatar> > matchingAvatars = avatars.Where(keyValuePair => keyValuePair.Value == avatar).ToList(); foreach (KeyValuePair <int, RealtimeAvatar> matchingAvatar in matchingAvatars) { avatars.Remove(matchingAvatar.Key); } }
public void _RegisterAvatar(int clientID, RealtimeAvatar avatar) { if (avatars.ContainsKey(clientID)) { Debug.LogError("RealtimeAvatar registered more than once for the same clientID (" + clientID + "). This is a bug!"); } avatars[clientID] = avatar; // Fire event if (avatarCreated != null) { try { avatarCreated(this, avatar, clientID == _realtime.clientID); } catch (System.Exception exception) { Debug.LogException(exception); } } }