private Environment() { messagingControllersManager = new MessagingControllersManager(); pointerEventsController = new PointerEventsController(); memoryManager = new MemoryManager(); clipboard = Clipboard.Create(); }
void Update() { MessagingControllersManager messagingManager = Environment.i.messaging.manager as MessagingControllersManager; int messagesProcessedLastFrame = lastPendingMessages - messagingManager.pendingMessagesCount; if (messagesProcessedLastFrame > 0) { sampleCount++; mps += 1 / (Time.deltaTime / messagesProcessedLastFrame); statsPanel.SetCellText(1, (int)Rows.MESSAGES_PER_SECOND_REAL, (mps / sampleCount).ToString(CultureInfo.InvariantCulture)); } lastPendingMessages = messagingManager.pendingMessagesCount; }
private IEnumerator RefreshProfilingData() { while (true) { int sharedCount = 0; int sharedAttachCount = 0; int componentCount = 0; int entityCount = 0; int materialCount = 0; int meshesCount = 0; var loadedScenes = Environment.i.world.state.loadedScenes; foreach (var v in loadedScenes) { if (v.Value.metricsController != null) { meshesCount += v.Value.metricsController.GetModel().meshes; materialCount += v.Value.metricsController.GetModel().materials; } sharedCount += v.Value.disposableComponents.Count; foreach (var e in v.Value.disposableComponents) { sharedAttachCount += e.Value.attachedEntities.Count; } entityCount += v.Value.entities.Count; foreach (var e in v.Value.entities) { componentCount += e.Value.components.Count; } } statsPanel.SetCellText(1, (int)Rows.SHARED_OBJECTS_COUNT, sharedCount.ToString()); statsPanel.SetCellText(1, (int)Rows.COMPONENT_OBJECTS_COUNT, componentCount.ToString()); statsPanel.SetCellText(1, (int)Rows.ENTITY_OBJECTS_COUNT, entityCount.ToString()); statsPanel.SetCellText(1, (int)Rows.MATERIAL_COUNT, materialCount.ToString()); statsPanel.SetCellText(1, (int)Rows.MESHES_COUNT, meshesCount.ToString()); statsPanel.SetCellText(1, (int)Rows.GLTF_BEING_LOADED, UnityGLTF.GLTFComponent.downloadingCount.ToString() + " ... In Queue: " + UnityGLTF.GLTFComponent.queueCount.ToString()); statsPanel.SetCellText(1, (int)Rows.AB_BEING_LOADED, AssetPromise_AB.downloadingCount.ToString() + " ... In Queue: " + AssetPromise_AB.queueCount.ToString()); statsPanel.SetCellText(1, (int)Rows.RENDERER_UNLOCK_SEGS, RenderingController.firstActivationTime.ToString(CultureInfo.InvariantCulture)); string busesLog = ""; Dictionary <string, int> pendingMessagesCount = new Dictionary <string, int>(); Dictionary <string, int> messagesReplaced = new Dictionary <string, int>(); MessagingControllersManager messagingManager = Environment.i.messaging.manager as MessagingControllersManager; using (var controllersIter = messagingManager.messagingControllers.GetEnumerator()) { while (controllersIter.MoveNext()) { using (var iterator = controllersIter.Current.Value.messagingBuses.GetEnumerator()) { while (iterator.MoveNext()) { //access to pair using iterator.Current MessagingBusType key = iterator.Current.Key; MessagingBus bus = controllersIter.Current.Value.messagingBuses[key]; string keyString = key.ToString(); if (!pendingMessagesCount.ContainsKey(keyString)) { pendingMessagesCount[keyString] = 0; } if (!messagesReplaced.ContainsKey(keyString)) { messagesReplaced[keyString] = 0; } pendingMessagesCount[keyString] += bus.pendingMessagesCount; messagesReplaced[keyString] += bus.unreliableMessagesReplaced; } } } } busesLog += $"{MessagingBusType.UI.ToString()} bus: {pendingMessagesCount[MessagingBusType.UI.ToString()]} replaced: {messagesReplaced[MessagingBusType.UI.ToString()]}\n"; busesLog += $"{MessagingBusType.INIT.ToString()} bus: {pendingMessagesCount[MessagingBusType.INIT.ToString()]} replaced: {messagesReplaced[MessagingBusType.INIT.ToString()]}\n"; busesLog += $"{MessagingBusType.SYSTEM.ToString()} bus: {pendingMessagesCount[MessagingBusType.SYSTEM.ToString()]} replaced: {messagesReplaced[MessagingBusType.SYSTEM.ToString()]}\n"; statsPanel.SetCellText(1, (int)Rows.MESSAGE_BUSES, busesLog); yield return(WaitForSecondsCache.Get(0.2f)); } }