Exemplo n.º 1
0
 private void Start()
 {
     peerConnectionManager = NetworkScene.FindNetworkScene(this).
                             GetComponentInChildren <VoipPeerConnectionManager>();
     if (peerConnectionManager)
     {
         peerConnectionManager.OnPeerConnection.AddListener(OnPeerConnection, true);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Find the AvatarManager for forest the Component is a member of. May return null if there is no AvatarManager for the scene.
 /// </summary>
 public static AvatarManager Find(MonoBehaviour Component)
 {
     try
     {
         return(NetworkScene.FindNetworkScene(Component).GetComponentInChildren <AvatarManager>());
     }
     catch
     {
         return(null);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Find the VoipConnectionManager for forest the Component is a member of. May return null if there is no Voip manager for the scene.
 /// </summary>
 public static VoipPeerConnectionManager Find(MonoBehaviour Component)
 {
     try
     {
         return(NetworkScene.FindNetworkScene(Component).GetComponentInChildren <VoipPeerConnectionManager>());
     }
     catch
     {
         return(null);
     }
 }
Exemplo n.º 4
0
        private bool TryGetAvatarManager(out AvatarManager avatarManager)
        {
            try {
                avatarManager = NetworkScene.FindNetworkScene(this)
                                .GetComponentInChildren <AvatarManager>();
            }
            catch (System.NullReferenceException)
            {
                avatarManager = null;
            }

            return(avatarManager);
        }
Exemplo n.º 5
0
        private void SetTexture(Texture2D texture)
        {
            if (!networkScene)
            {
                networkScene = NetworkScene.FindNetworkScene(this);
                if (!networkScene)
                {
                    return;
                }
            }

            var avatar         = networkScene.GetComponentInChildren <AvatarManager>().LocalAvatar;
            var texturedAvatar = avatar.GetComponent <TexturedAvatar>();

            if (texturedAvatar)
            {
                texturedAvatar.SetTexture(texture);
            }
        }
Exemplo n.º 6
0
        public static void ChangeScene(MonoBehaviour caller, string sceneName)
        {
            var manager = FindSceneManager(NetworkScene.FindNetworkScene(caller));

            manager.ChangeScene(sceneName);
        }
Exemplo n.º 7
0
        public static GameObject SpawnPersistent(MonoBehaviour caller, GameObject prefab)
        {
            var spawner = FindNetworkSpawner(NetworkScene.FindNetworkScene(caller));

            return(spawner.SpawnPersistent(prefab));
        }