private static void pluginManager_PluginsRemoving(object sender, DualityPluginEventArgs e) { // Dispose any existing Resources that could reference plugin data //VisualLog.ClearAll(); if (!Scene.Current.IsEmpty) { Scene.Current.Dispose(); } foreach (Resource r in ContentProvider.EnumeratePluginContent().ToArray()) { ContentProvider.RemoveContent(r.Path); } }
private void Dispose(bool manually) { if (this.initState == InitState.Initialized) { this.initState = InitState.Disposing; if (ResourceDisposing != null) { ResourceDisposing(this, new ResourceEventArgs(this)); } this.OnDisposing(manually); ContentProvider.RemoveContent(this, false); this.initState = InitState.Disposed; } }
private static void OnDiscardPluginData(IEnumerable <CorePlugin> oldPlugins) { oldPlugins = oldPlugins.NotNull().Distinct(); if (!oldPlugins.Any()) { oldPlugins = null; } if (DiscardPluginData != null) { DiscardPluginData(null, EventArgs.Empty); } // Clean globally cached type values availTypeDict.Clear(); ReflectionHelper.ClearTypeCache(); Component.ClearTypeCache(); // Dispose any existing Resources that could reference plugin data if (!Scene.Current.IsEmpty) { Scene.Current.Dispose(); } foreach (Resource r in ContentProvider.EnumeratePluginContent().ToArray()) { ContentProvider.RemoveContent(r.Path); } // Clean input sources that a disposed Assembly forgot to unregister. if (oldPlugins != null) { foreach (CorePlugin plugin in oldPlugins) { CleanInputSources(plugin.PluginAssembly); } } // Clean event bindings that are still linked to the disposed Assembly. if (oldPlugins != null) { foreach (CorePlugin plugin in oldPlugins) { CleanEventBindings(plugin.PluginAssembly); } } }
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); } }
private static void pluginManager_PluginsRemoving(object sender, DualityPluginEventArgs e) { // Wrapper method for delivering the old API until removing it in v3.0 if (DiscardPluginData != null) { DiscardPluginData(sender, e); } // Dispose any existing Resources that could reference plugin data VisualLog.ClearAll(); if (!Scene.Current.IsEmpty) { Scene.Current.Dispose(); } foreach (Resource r in ContentProvider.EnumeratePluginContent().ToArray()) { ContentProvider.RemoveContent(r.Path); } }
private void Dispose(bool manually) { if (this.initState == InitState.Initialized) { this.initState = InitState.Disposing; // Invoke external and internal handlers for resource disposal if (ResourceDisposing != null) { ResourceDisposing(this, new ResourceEventArgs(this)); } this.OnDisposing(manually); this.initState = InitState.Disposed; // Remove the resource from the central registry ContentProvider.RemoveContent(this, false); } }