/// <summary> /// Performs a single update cycle. /// </summary> /// <param name="forceFixedStep">If true use a timestep thats equal to <see cref="Time.MillisecondsPerFrame"/> for the update</param> public static void Update(bool forceFixedStep) { isUpdating = true; Profile.TimeUpdate.BeginMeasure(); Time.FrameTick(forceFixedStep, true); Profile.FrameTick(); VisualLogs.UpdateLogEntries(); pluginManager.InvokeBeforeUpdate(); UpdateUserInput(); Scene.Current.Update(); sound.Update(); pluginManager.InvokeAfterUpdate(); VisualLogs.PrepareRenderLogEntries(); // Perform a cleanup step to catch all DisposeLater calls from this update RunCleanup(); // Perform any previously scheduled Scene switch Scene.PerformScheduledSwitch(); Profile.TimeUpdate.EndMeasure(); isUpdating = false; if (terminateScheduled) { Terminate(); } }
private static void pluginManager_PluginsRemoving(object sender, DualityPluginEventArgs e) { // Save user and app data, they'll be reloaded after plugin reload is done, // as they can reference plugin data as well. DualityApp.UserData.Save(); DualityApp.AppData.Save(); // Dispose static Resources that could reference plugin data VisualLogs.ClearAll(); if (!Scene.Current.IsEmpty) { Scene.Current.Dispose(); } // Gather all other Resources that could reference plugin data List <Resource> pluginContent = new List <Resource>(); Assembly coreAssembly = typeof(Resource).GetTypeInfo().Assembly; foreach (Resource resource in ContentProvider.GetLoadedContent <Resource>()) { if (resource.IsDefaultContent) { continue; } Assembly assembly = resource.GetType().GetTypeInfo().Assembly; bool canReferencePluginData = resource is Prefab || resource is Scene || assembly != coreAssembly; if (canReferencePluginData) { pluginContent.Add(resource); } } // Dispose gathered content to avoid carrying over old instances by accident foreach (Resource r in pluginContent) { ContentProvider.RemoveContent(r); } }
internal static void EditorUpdate(IEnumerable <GameObject> updateObjects, bool simulateGame, bool forceFixedStep) { isUpdating = true; Profile.TimeUpdate.BeginMeasure(); Time.FrameTick(forceFixedStep, simulateGame); Profile.FrameTick(); if (simulateGame) { VisualLogs.UpdateLogEntries(); pluginManager.InvokeBeforeUpdate(); UpdateUserInput(); Scene.Current.Update(); List <ICmpUpdatable> updatables = new List <ICmpUpdatable>(); foreach (GameObject obj in updateObjects) { if (obj.Scene == Scene.Current) { continue; } updatables.Clear(); obj.GetComponents(updatables); for (int i = 0; i < updatables.Count; i++) { if (!(updatables[i] as Component).Active) { continue; } updatables[i].OnUpdate(); } } pluginManager.InvokeAfterUpdate(); } else { Scene.Current.EditorUpdate(); List <ICmpUpdatable> updatables = new List <ICmpUpdatable>(); foreach (GameObject obj in updateObjects) { updatables.Clear(); obj.GetComponents(updatables); for (int i = 0; i < updatables.Count; i++) { if (!(updatables[i] as Component).Active) { continue; } updatables[i].OnUpdate(); } } } sound.Update(); VisualLogs.PrepareRenderLogEntries(); // Perform a cleanup step to catch all DisposeLater calls from this update RunCleanup(); if (simulateGame) { // Perform any previously scheduled Scene switch Scene.PerformScheduledSwitch(); } Profile.TimeUpdate.EndMeasure(); isUpdating = false; if (terminateScheduled) { Terminate(); } }