private ZoneLoadStatus ChangeZone(ZoneData to, bool waitForConnections) { var from = Player.Instance.Zone; var loader = new ZoneLoadStatus { IsDone = false }; if (from != null) { LeaveZone(from, to); } if (to != null) { if (to.State == ZoneState.Loaded && !waitForConnections) { EnteringLoadedZone(loader, to, from); } else { StartCoroutine(EnteringUnloadedZone(loader, from, to, waitForConnections)); } } else { loader.IsDone = true; } return(loader); }
private IEnumerator EnteringUnloadedZone(ZoneLoadStatus status, ZoneData from, ZoneData to, bool waitForConnections) { Freeze(); if (to.State == ZoneState.Unloaded || to.State == ZoneState.Unloading) { yield return(LoadZone(to)); } while (to.State == ZoneState.Loading) { yield return(null); } if (waitForConnections) { yield return(LoadConnections(to, from)); } else { StartCoroutine(LoadConnections(to, from)); } EnteringZone(to, from); status.IsDone = true; Thaw(); }
private IEnumerator UnloadAssets(ZoneLoadStatus status) { while (!status.IsDone) { yield return(null); } yield return(Resources.UnloadUnusedAssets()); }
private void EnteringLoadedZone(ZoneLoadStatus status, ZoneData to, ZoneData from) { StartCoroutine(LoadConnections(to, from)); EnteringZone(to, from); status.IsDone = true; }