Exemple #1
0
        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 CreateAvatarIfNeeded()
        {
            if (!_realtime.connected)
            {
                Debug.LogError("RealtimeAvatarManager: Unable to create avatar. Realtime is not connected to a room.");
                return;
            }

            if (localAvatar != null)
            {
                return;
            }

            if (_localAvatarPrefab == null)
            {
                Debug.LogWarning("Realtime Avatars local avatar prefab is null. No avatar prefab will be instantiated for the local player.");
                return;
            }

            if (localOfflineAvatar != null)
            {
                localOfflineAvatar.SetActive(false);
            }

            GameObject avatarGameObject = Realtime.Instantiate(_localAvatarPrefab.name, true, true, true, _realtime);

            if (avatarGameObject == null)
            {
                Debug.LogError("RealtimeAvatarManager: Failed to instantiate RealtimeAvatar prefab for the local player.");
                return;
            }

            localAvatar = avatarGameObject.GetComponent <RealtimeAvatar>();
            if (avatarGameObject == null)
            {
                Debug.LogError("RealtimeAvatarManager: Successfully instantiated avatar prefab, but could not find the RealtimeAvatar component.");
                return;
            }
            localAvatar.transform.position = localOfflineAvatar.transform.position;

            localAvatar.localPlayer = _localPlayer;
            localAvatar.deviceType  = GetRealtimeAvatarDeviceTypeForLocalPlayer();

            string avatarName = PlayerPrefs.GetString("PlayerName", "Avatar");

            localAvatar.GetComponent <AvatarAppearance>().SetName(avatarName);
            localAvatar.GetComponent <AvatarAppearance>().UpdateAvatarName();
        }
Exemple #3
0
        public void CreateAvatarIfNeeded()
        {
            if (!_realtime.connected)
            {
                Debug.LogError("RealtimeAvatarManager: Unable to create avatar. Realtime is not connected to a room.");
                return;
            }

            if (localAvatar != null)
            {
                return;
            }

            if (_localAvatarPrefab == null)
            {
                Debug.LogWarning("Realtime Avatars local avatar prefab is null. No avatar prefab will be instantiated for the local player.");
                return;
            }

            GameObject avatarGameObject = Realtime.Instantiate(_localAvatarPrefab.name, true, true, true, _realtime);

            if (avatarGameObject == null)
            {
                Debug.LogError("RealtimeAvatarManager: Failed to instantiate RealtimeAvatar prefab for the local player.");
                return;
            }

            localAvatar = avatarGameObject.GetComponent <RealtimeAvatar>();
            if (localAvatar == null)
            {
                Debug.LogError("RealtimeAvatarManager: Successfully instantiated avatar prefab, but could not find the RealtimeAvatar component.");
                return;
            }

            localAvatar.localPlayer = _localPlayer;
            localAvatar.deviceType  = GetRealtimeAvatarDeviceTypeForLocalPlayer();
            localAvatar.deviceModel = XRDevice.model;
        }