public void LateUpdate() { TileCache.MarkAllUnused(); _lateUpdate(); RequestManager.ForEachQueuedDownload(DerateUnusedTilePriority); RequestManager.ForEachActiveDownload(DerateUnusedTilePriority); TileCache.ForEach(DerateUnusedTilePriority); int maxNewRequests = TileCache.HasMaxSize ? TileCache.MaxSize - TileCache.Count() : -1; RequestManager.Process(maxNewRequests); int processed = 0; while (processed < SceneOptions.MaximumTilesToProcessPerFrame && ProcessingQueue.Count != 0) { var tile = ProcessingQueue.Dequeue(); if (tile.Process()) //bake colliders, load indices, etc... { // We allow requests to terminate early if the (would be) tile goes out of view, so check if a tile // is actually processed processed++; } } //if there are queued requests with higher priority than existing tiles but the TileCache cache is too full //to allow them to load, unload a corresponding number of lowest-priority tiles int ejected = 0; if (maxNewRequests >= 0 && maxNewRequests < SceneOptions.MaxConcurrentRequests && RequestManager.Count() > maxNewRequests) { var re = RequestManager.GetEnumerator(); //high priority (low value) first ejected = TileCache.MarkLowPriorityUnused(t => //low priority (high value) first re.MoveNext() && t.FrameState.Priority > re.Current.FrameState.Priority, SceneOptions.MaxConcurrentRequests - maxNewRequests); } if (ejected > 0 || (TileCache.TargetSize > 0 && TileCache.Count() > TileCache.TargetSize)) { //this will trigger Resources.UnloadUnusedAssets() as needed TileCache.UnloadUnusedContent(ejected); } if (unloadAssetsPending) { if (lastUnloadAssets == null || lastUnloadAssets.isDone) { unloadAssetsPending = false; lastUnloadAssets = Resources.UnloadUnusedAssets(); } } UpdateStats(); }
public void UpdateStats() { Statistics.RequestQueueLength = RequestManager.Count(t => t.Tileset == this); Statistics.ActiveDownloads = RequestManager.CountActiveDownloads(t => t.Tileset == this); Statistics.ProcessingQueueLength = ProcessingQueue.Count(t => t.Tileset == this); Statistics.DownloadedTiles = TileCache.Count(t => t.Tileset == this); Statistics.ReadyTiles = TileCache.Count(t => t.Tileset == this && t.ContentState == Unity3DTileContentState.READY); Unity3DTilesetStatistics.MaxLoadedTiles = TileCache.MaxSize; }