void IModule.LoadModule() { CleanupVisuals(); const float rescanSleepTime = 0.5f; const float updateSleepTime = 0.03f; m_RescanTask = new EditorSlowTask(ScanEntitiesAndCreateVisuals, rescanSleepTime); m_UpdateTask = new EditorSlowTask(UpdateVisuals, updateSleepTime); m_SlowTaskModule.AddSlowTask(ScanEntitiesAndCreateVisuals, rescanSleepTime, true); m_SlowTaskModule.AddSlowTask(UpdateVisuals, updateSleepTime, true); m_Loaded = true; #if UNITY_EDITOR EditorApplication.delayCall += () => { if (m_Loaded && !EditorApplication.isPlayingOrWillChangePlaymode) { EditorApplication.update += EditorUpdateSlowTask; } }; EditorOnlyDelegates.IsGizmosCamera = IsGizmosCamera; Selection.selectionChanged += OnSelectionChanged; #endif }
void RegisterMultipleDummyTasks(int count) { for (var i = 0; i < count; i++) { var dummyNumber = i + 1; Action action = () => { DummyAction(dummyNumber); }; Assert.True(m_Module.AddSlowTask(action, k_DefaultInterval)); } var moduleBehaviour = (IModuleBehaviorCallbacks)m_Module; moduleBehaviour.OnBehaviorUpdate(); }
void ServiceStartTask() { #if UNITY_MARS_USE_LOCATION var service = Input.location; switch (service.status) { case LocationServiceStatus.Stopped: { if (Input.location.isEnabledByUser) { Input.location.Start(m_DesiredAccuracy, m_UpdateDistance); } else { Debug.Log("Location service not enabled by user"); m_SlowTaskModule.RemoveSlowTask(ServiceStartTask); } break; } case LocationServiceStatus.Failed: { if (MarsDebugSettings.GeoLocationModuleLogging) { if (!service.isEnabledByUser) { Debug.LogWarning("Location service start failed - user has location disabled"); } else { Debug.LogWarning("Location service start failed - unknown reason"); } } m_SlowTaskModule.RemoveSlowTask(ServiceStartTask); break; } case LocationServiceStatus.Initializing: { if (m_InitializationTimeCounter > 0) { m_InitializationTimeCounter--; } else { if (MarsDebugSettings.GeoLocationModuleLogging) { Debug.LogWarningFormat("Location service start timed out after {0} seconds", m_InitializationTimeout); } m_SlowTaskModule.RemoveSlowTask(ServiceStartTask); } break; } case LocationServiceStatus.Running: { m_SlowTaskModule.RemoveSlowTask(ServiceStartTask); if (m_ContinuousUpdates) { m_SlowTaskModule.AddSlowTask(UpdateLocationTask, m_UpdateInterval); } m_CurrentLocation = Input.location.lastData; AddOrUpdateLocationTrait(); // since GPS has significant power overhead, unless we've explicitly asked for continuous updates, // stop the service once we've ascertained location. It can be restarted later if needed. if (!m_ContinuousUpdates) { Input.location.Stop(); } break; } } #endif }