/// <inheritdoc/> public override void Highlight(IEditorGameController controller, EditorServiceGame game, AssetItem assetItem, float duration) { var dependencies = DependencyManager.ComputeDependencies(assetItem.Id, AssetDependencySearchOptions.In, ContentLinkType.Reference); if (dependencies == null) { return; } foreach (var dependency in dependencies.LinksIn.Where(x => x.Item.Asset is MaterialAsset)) { var referencer = assetItem.Package.Session.FindAsset(dependency.Item.Id); if (referencer == null) { continue; } var material = controller.Loader.GetRuntimeObject <Material>(referencer); if (material != null) { lock (highlightedMaterials) { highlightedMaterials[material] = DirectReferenceColor; } var currentMaterial = material; controller.InvokeTask(() => HighlightMaterial(game, currentMaterial, duration)); } var subDependencies = DependencyManager.ComputeDependencies(referencer.Id, AssetDependencySearchOptions.In | AssetDependencySearchOptions.Recursive, ContentLinkType.Reference); if (subDependencies == null) { continue; } foreach (var subDependency in subDependencies.LinksIn.Where(x => x.Item.Asset is MaterialAsset)) { referencer = assetItem.Package.Session.FindAsset(subDependency.Item.Id); if (referencer == null) { continue; } material = controller.Loader.GetRuntimeObject <Material>(referencer); if (material != null) { lock (highlightedMaterials) { highlightedMaterials[material] = IndirectReferenceColor; } var currentMaterial = material; controller.InvokeTask(() => HighlightMaterial(game, currentMaterial, duration)); } } } }
private async Task ReloadGraphicsCompositor(bool forceIfSame) { var graphicsCompositorId = AttachedReferenceManager.GetAttachedReference(settingsProvider.CurrentGameSettings.GraphicsCompositor)?.Id; var graphicsCompositorAsset = (GraphicsCompositorViewModel)(graphicsCompositorId.HasValue ? editor.Session.GetAssetById(graphicsCompositorId.Value) : null); // Same compositor as before? if (graphicsCompositorAsset == currentGraphicsCompositorAsset && !forceIfSame) { return; } // TODO: Start listening for changes in this compositor currentGraphicsCompositorAsset = graphicsCompositorAsset; // TODO: If nothing, fallback to default compositor, or stop rendering? if (graphicsCompositorAsset == null) { return; } // TODO: Prevent reentrency var database = editor.ServiceProvider.Get <GameStudioDatabase>(); await database.Build(graphicsCompositorAsset.AssetItem); await controller.InvokeTask(async() => { using (await database.MountInCurrentMicroThread()) { // Unlaod previous graphics compositor if (loadedGraphicsCompositor != null) { game.Content.Unload(loadedGraphicsCompositor); loadedGraphicsCompositor = null; } else { // Should only happen when graphics compositor is fallback one (i.e. first load or failure) game.SceneSystem.GraphicsCompositor?.Dispose(); } game.SceneSystem.GraphicsCompositor = null; // Load and set new graphics compositor loadedGraphicsCompositor = game.Content.Load <GraphicsCompositor>(graphicsCompositorAsset.AssetItem.Location); game.UpdateGraphicsCompositor(loadedGraphicsCompositor); } }); }
/// <inheritdoc/> public override void Highlight(IEditorGameController controller, EditorServiceGame game, AssetItem assetItem, float duration) { var model = controller.Loader.GetRuntimeObject <Model>(assetItem); if (model != null) { lock (highlightedMeshes) { foreach (var mesh in model.Meshes) { highlightedMeshes[mesh] = DirectReferenceColor; var currentMesh = mesh; controller.InvokeTask(() => HighlightMesh(game, currentMesh, duration)); } } } }