protected override EntityComponent CreateComponentFromAsset(EntityHierarchyItemViewModel parent, AssetViewModel <TModelAsset> asset) { return(new ModelComponent { Model = ContentReferenceHelper.CreateReference <Model>(asset) }); }
protected override EntityComponent CreateComponentFromAsset(EntityHierarchyItemViewModel parent, SpriteStudioModelViewModel asset) { return(new SpriteStudioComponent { Sheet = ContentReferenceHelper.CreateReference <SpriteStudioSheet>(asset), }); }
protected override EntityComponent CreateComponentFromAsset(EntityHierarchyItemViewModel parent, AssetViewModel <VideoAsset> asset) { return(new VideoComponent { Source = ContentReferenceHelper.CreateReference <Video.Video>(asset) }); }
protected override EntityComponent CreateComponentFromAsset(EntityHierarchyItemViewModel parent, UIPageViewModel asset) { return(new UIComponent { Page = ContentReferenceHelper.CreateReference <UIPage>(asset) }); }
private async void CreateSkeleton() { var source = Asset.Source; if (UPath.IsNullOrEmpty(source)) { return; } using (var transaction = UndoRedoService.CreateTransaction()) { var template = Session.FindTemplates(TemplateScope.Asset).SingleOrDefault(x => x.Id == SkeletonFromFileTemplateGenerator.Id); if (template != null) { var viewModel = new TemplateDescriptionViewModel(ServiceProvider, template); var skeleton = (await Session.ActiveAssetView.RunAssetTemplate(viewModel, new[] { source })).SingleOrDefault(); if (skeleton == null) { return; } var skeletonNode = AssetRootNode[nameof(ModelAsset.Skeleton)]; var reference = ContentReferenceHelper.CreateReference <Skeleton>(skeleton); skeletonNode.Update(reference); } UndoRedoService.SetName(transaction, "Create Skeleton"); } }
protected override EntityComponent CreateComponentFromAsset(EntityHierarchyItemViewModel parent, AssetViewModel <TextureAsset> asset) { return(new SpriteComponent { SpriteProvider = new SpriteFromTexture { Texture = ContentReferenceHelper.CreateReference <Texture>(asset) } }); }
protected override EntityComponent CreateComponentFromAsset(EntityHierarchyItemViewModel parent, SpriteSheetViewModel asset) { return(new SpriteComponent { SpriteProvider = new SpriteFromSheet { Sheet = ContentReferenceHelper.CreateReference <SpriteSheet>(asset) } }); }
protected override async Task <bool> PrepareAssetCreation(AssetTemplateGeneratorParameters parameters) { if (!await base.PrepareAssetCreation(parameters)) { return(false); } var modelViewModel = await BrowseForAsset(parameters.Package, new[] { typeof(IModelAsset) }, new UFile(parameters.Name).GetFullDirectory(), "Select a model to use to generate the hull - _cancel to leave the model empty_"); var model = ContentReferenceHelper.CreateReference <Model>(modelViewModel); parameters.SetTag(ModelKey, model); return(true); }
protected override void ReplaceReference() { var referenceType = node.Descriptor.GetInnerCollectionType(); var newReference = ContentReferenceHelper.CreateReference(ReplacementObject, referenceType); if (node is IMemberNode) { ((IMemberNode)node).Update(newReference); } else { ((IObjectNode)node).Update(newReference, index); } }
protected override async Task <bool> PrepareAssetCreation(AssetTemplateGeneratorParameters parameters) { if (!await base.PrepareAssetCreation(parameters)) { return(false); } var acceptedTypes = AssetRegistry.GetAssetTypes(typeof(Texture)); var textureViewModel = await BrowseForAsset(parameters.Package, acceptedTypes, new UFile(parameters.Name).GetFullDirectory(), "Select a cubemap texture to use for this skybox - _cancel to leave the texture empty_"); var texture = ContentReferenceHelper.CreateReference <Texture>(textureViewModel); parameters.SetTag(TextureKey, texture); return(true); }
protected override async Task <bool> PrepareAssetCreation(AssetTemplateGeneratorParameters parameters) { if (!await base.PrepareAssetCreation(parameters)) { return(false); } var acceptedTypes = AssetRegistry.GetAssetTypes(typeof(Material)); var materialViewModel = await BrowseForAsset(parameters.Package, acceptedTypes, new UFile(parameters.Name).GetFullDirectory(), "Select a material to use for this model - _cancel to leave the material empty_"); var material = ContentReferenceHelper.CreateReference <Material>(materialViewModel); parameters.SetTag(MaterialKey, material); return(true); }
public override async Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent) { var model = await PickupAsset(parent.Editor.Session, new [] { typeof(IModelAsset) }); if (model == null) { return(null); } var name = ComputeNewName(parent, model.Name); var component = new ModelComponent { Model = ContentReferenceHelper.CreateReference <Model>(model) }; return(await CreateEntityWithComponent(name, component)); }
protected override void UpdateNode(IAssetNodePresenter node) { if (!(node.PropertyProvider is AssetViewModel) || node.Asset == null) { return; } // Add a link to the archetype in the root node, if there is an archetype for this asset. if (typeof(Asset).IsAssignableFrom(node.Type) && node.Asset.Asset.Archetype != null) { var session = node.Asset.Session; var archetype = session.GetAssetById(node.Asset.Asset.Archetype.Id); var assetReference = ContentReferenceHelper.CreateReference <AssetReference>(archetype); var archetypeNode = node.Factory.CreateVirtualNodePresenter(node, ArchetypeNodeName, typeof(AssetReference), int.MinValue, () => assetReference); archetypeNode.DisplayName = nameof(Asset.Archetype); archetypeNode.IsReadOnly = true; } }
public override async Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent) { var skybox = await PickupAsset(parent.Editor.Session, new[] { typeof(SkyboxAsset) }); if (skybox == null) { return(null); } var skyboxAsset = (SkyboxAsset)skybox.Asset; var name = ComputeNewName(parent, "Skybox light"); var lightComponent = new LightComponent { Type = new LightSkybox { Skybox = ContentReferenceHelper.CreateReference <Skybox>(skybox) } }; var skyboxComponent = new BackgroundComponent { Texture = skyboxAsset.CubeMap }; return(await CreateEntityWithComponent(name, lightComponent, skyboxComponent)); }
/// <summary> /// Creates the content reference corresponding to the given asset. /// </summary> /// <param name="asset">The asset for which to create a content reference.</param> /// <param name="referenceType">The type of content reference to create.</param> /// <returns>A content reference corresponding to the given asset.</returns> protected virtual object CreateReference(AssetViewModel asset, Type referenceType) { return(ContentReferenceHelper.CreateReference(asset, referenceType)); }
protected override async Task <bool> PrepareAssetCreation(AssetTemplateGeneratorParameters parameters) { var result = await base.PrepareAssetCreation(parameters); if (!result) { return(false); } var files = parameters.Tags.Get(SourceFilesPathKey); if (files is null) { return(true); } var showDeduplicateMaterialsCheckBox = files.Any(x => ImportAssimpCommand.IsSupportingExtensions(x.GetFileExtension())); var showFbxDedupeNotSupportedWarning = showDeduplicateMaterialsCheckBox && files.Any(x => ImportFbxCommand.IsSupportingExtensions(x.GetFileExtension())); // Load settings from the last time this template was used for this project var profile = parameters.Package.UserSettings.Profile; var window = new ModelAssetTemplateWindow { Parameters = { ImportMaterials = ModelFromFileTemplateSettings.ImportMaterials.GetValue(profile, true), ShowDeduplicateMaterialsCheckBox = showDeduplicateMaterialsCheckBox, ShowFbxDedupeNotSupportedWarning = showFbxDedupeNotSupportedWarning, DeduplicateMaterials = ModelFromFileTemplateSettings.DeduplicateMaterials.GetValue(profile, true), ImportTextures = ModelFromFileTemplateSettings.ImportTextures.GetValue(profile, true), ImportSkeleton = ModelFromFileTemplateSettings.ImportSkeleton.GetValue(profile, true) } }; var skeletonId = ModelFromFileTemplateSettings.DefaultSkeleton.GetValue(); var skeleton = SessionViewModel.Instance?.GetAssetById(skeletonId); if (skeleton != null) { window.Parameters.ReuseSkeleton = true; window.Parameters.SkeletonToReuse = ContentReferenceHelper.CreateReference <Skeleton>(skeleton); } await window.ShowModal(); if (window.Result == DialogResult.Cancel) { return(false); } // Apply settings var skeletonToReuse = window.Parameters.ReuseSkeleton ? window.Parameters.SkeletonToReuse : null; parameters.Tags.Set(ImportMaterialsKey, window.Parameters.ImportMaterials); parameters.Tags.Set(DeduplicateMaterialsKey, window.Parameters.DeduplicateMaterials); parameters.Tags.Set(ImportTexturesKey, window.Parameters.ImportTextures); parameters.Tags.Set(ImportSkeletonKey, window.Parameters.ImportSkeleton); parameters.Tags.Set(SkeletonToUseKey, skeletonToReuse); // Save settings ModelFromFileTemplateSettings.ImportMaterials.SetValue(window.Parameters.ImportMaterials, profile); ModelFromFileTemplateSettings.DeduplicateMaterials.SetValue(window.Parameters.DeduplicateMaterials, profile); ModelFromFileTemplateSettings.ImportTextures.SetValue(window.Parameters.ImportTextures, profile); ModelFromFileTemplateSettings.ImportSkeleton.SetValue(window.Parameters.ImportSkeleton, profile); skeletonId = AttachedReferenceManager.GetAttachedReference(skeletonToReuse)?.Id ?? AssetId.Empty; ModelFromFileTemplateSettings.DefaultSkeleton.SetValue(skeletonId, profile); parameters.Package.UserSettings.Save(); return(true); }
private void UpdateGameSettings(SceneViewModel scene) { Asset.DefaultScene = ContentReferenceHelper.CreateReference <Scene>(scene); }