Esempio n. 1
0
        public override async Task <AssetViewModel> PickupObject(AssetViewModel objectToFix, object referencedMember)
        {
            var assetPicker = ServiceProvider.Get <IEditorDialogService>().CreateAssetPickerDialog(objectToFix.Session);

            assetPicker.Message             = "Select an asset to replace the deleted asset";
            assetPicker.Filter              = x => !IsInObjectsToFixList(x);
            assetPicker.InitialLocation     = objectToFix.Directory;
            assetPicker.AllowMultiSelection = false;
            Type assetType   = objectToFix.AssetType;
            var  contentType = AssetRegistry.GetContentType(objectToFix.AssetType);

            if (contentType != null)
            {
                var assetTypes = AssetRegistry.GetAssetTypes(contentType);
                assetPicker.AcceptedTypes.AddRange(assetTypes);
            }
            else
            {
                assetPicker.AcceptedTypes.Add(assetType);
            }

            var result = await assetPicker.ShowModal();

            return(result == DialogResult.Ok ? assetPicker.SelectedAssets.First() : null);
        }
Esempio n. 2
0
 public override IEnumerable <Type> GetInputTypesToExclude(AssetItem assetItem)
 {
     foreach (var type in AssetRegistry.GetAssetTypes(typeof(Material)))
     {
         yield return(type);
     }
     yield return(typeof(TextureAsset));
 }
        public override bool CanAddChildren(IReadOnlyCollection <object> children, AddChildModifiers modifiers, out string message)
        {
            AssetViewModel asset       = null;
            var            singleChild = true;

            foreach (var child in children)
            {
                if (!singleChild)
                {
                    message = "Multiple assets selected";
                    return(false);
                }
                asset = child as AssetViewModel;
                if (asset == null)
                {
                    message = "The selection is not an asset";
                    return(false);
                }
                if (AssetRegistry.IsContentType(TargetNode.Type) || typeof(AssetReference).IsAssignableFrom(TargetNode.Type))
                {
                    var isCompatible       = false;
                    var resolvedAssetTypes = AssetRegistry.GetAssetTypes(TargetNode.Type);
                    foreach (var resolvedAssetType in resolvedAssetTypes)
                    {
                        if (resolvedAssetType.IsAssignableFrom(asset.AssetType))
                        {
                            isCompatible = true;
                            break;
                        }
                    }
                    if (!isCompatible)
                    {
                        message = "Incompatible asset";
                        return(false);
                    }
                }
                var command = TargetNode.GetCommand("SetContentReference");
                var param   = new SetContentReferenceCommand.Parameter {
                    Asset = asset, Type = TargetNode.Type
                };
                if (!command.CanExecute(param))
                {
                    message = "The selection is not valid in this context";
                    return(false);
                }

                singleChild = false;
            }
            if (asset == null)
            {
                message = "The selection is not an asset";
                return(false);
            }
            message = $"Reference {asset.Url}";
            return(true);
        }
Esempio n. 4
0
        public override IEnumerable <BuildDependencyInfo> GetInputTypes(AssetItem assetItem)
        {
            // We need to read the prefab asset to collect models
            yield return(new BuildDependencyInfo(typeof(PrefabAsset), typeof(AssetCompilationContext), BuildDependencyType.CompileAsset));

            foreach (var type in AssetRegistry.GetAssetTypes(typeof(Model)))
            {
                yield return(new BuildDependencyInfo(type, typeof(AssetCompilationContext), BuildDependencyType.CompileContent));
            }
        }
 public override IEnumerable <BuildDependencyInfo> GetInputTypes(AssetItem assetItem)
 {
     foreach (var type in AssetRegistry.GetAssetTypes(typeof(Model)))
     {
         yield return(new BuildDependencyInfo(type, typeof(AssetCompilationContext), BuildDependencyType.CompileContent));
     }
     foreach (var type in AssetRegistry.GetAssetTypes(typeof(Skeleton)))
     {
         yield return(new BuildDependencyInfo(type, typeof(AssetCompilationContext), BuildDependencyType.CompileContent));
     }
 }
        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);
        }
Esempio n. 8
0
        public override IEnumerable <BuildDependencyInfo> GetInputTypes(AssetItem assetItem)
        {
            foreach (var type in AssetRegistry.GetAssetTypes(typeof(Model)))
            {
                yield return(new BuildDependencyInfo(type, typeof(AssetCompilationContext), BuildDependencyType.Runtime));
            }
            foreach (var type in AssetRegistry.GetAssetTypes(typeof(AnimationClip)))
            {
                yield return(new BuildDependencyInfo(type, typeof(AssetCompilationContext), BuildDependencyType.Runtime));
            }
            yield return(new BuildDependencyInfo(typeof(TextureAsset), typeof(AssetCompilationContext), BuildDependencyType.Runtime));

            yield return(new BuildDependencyInfo(typeof(PrefabAsset), typeof(AssetCompilationContext), BuildDependencyType.Runtime));

            yield return(new BuildDependencyInfo(typeof(MaterialAsset), typeof(AssetCompilationContext), BuildDependencyType.Runtime));

            yield return(new BuildDependencyInfo(typeof(SpriteSheetAsset), typeof(AssetCompilationContext), BuildDependencyType.Runtime));
        }
Esempio n. 9
0
 protected override void UpdateNode(IAssetNodePresenter node)
 {
     if (AssetRegistry.IsContentType(node.Type) || typeof(AssetReference).IsAssignableFrom(node.Type))
     {
         node.AttachedProperties.Add(SessionData.SessionKey, session);
         node.AttachedProperties.Add(ReferenceData.Key, new ContentReferenceViewModel());
     }
     // Numeric and TimeSpan templates need access to the UndoRedoService to create transactions
     if (node.Type == typeof(TimeSpan) || node.Type.IsNumeric())
     {
         node.AttachedProperties.Add(SessionData.SessionKey, session);
     }
     if (AssetRegistry.IsContentType(node.Type))
     {
         var assetTypes       = AssetRegistry.GetAssetTypes(node.Type);
         var thumbnailService = session.ServiceProvider.Get <IThumbnailService>();
         node.AttachedProperties.Add(SessionData.DynamicThumbnailKey, !assetTypes.All(thumbnailService.HasStaticThumbnail));
     }
 }
Esempio n. 10
0
 protected virtual IEnumerable <Type> GetAssetTypes(Type contentType)
 {
     return(AssetRegistry.GetAssetTypes(contentType));
 }