Exemplo n.º 1
0
 public RoomBuilder SetConnectedRoom(RoomIndicator connectedRoomInd)
 {
     if (connectedRoomInd != null)
     {
         ConnectedRoomInd = connectedRoomInd;
     }
     return(this);
 }
Exemplo n.º 2
0
 public RoomBuilder SetConnectedRoom(Guid?connectedRoomId)
 {
     if (connectedRoomId.HasValue)
     {
         ConnectedRoomInd = new RoomIndicator(connectedRoomId.Value);
     }
     return(this);
 }
Exemplo n.º 3
0
    private void EstablishConnections(Scene scene)
    {
        //Search for array of connected scenes from RoomIndicator object in new scene
        List <string> nameList = new List <string>();

        foreach (GameObject go in scene.GetRootGameObjects())
        {
            RoomIndicator indicator = go.GetComponentInChildren <RoomIndicator>();
            if (indicator != null)
            {
                nameList.Add(indicator.GetConnectedRoom());
            }
        }

        string[] nameArray = nameList.ToArray();

        //Unload all unused scenes
        for (int i = 0; i < SceneManager.sceneCount; i++)
        {
            Scene currentScene = SceneManager.GetSceneAt(i);
            if (currentScene != scene)
            {
                //SceneManager.UnloadSceneAsync(currentScene);
            }
        }

        //Load new connected scenes
        if (nameArray != null)
        {
            foreach (string name in nameArray)
            {
                if (SceneManager.GetSceneByName(name).buildIndex == -1)
                {
                    SceneManager.LoadSceneAsync(name, LoadSceneMode.Additive);
                }
            }
        }
    }