/// <inheritdoc/> public override Task <ResultStatus> Execute(IExecuteContext executeContext, BuilderContext builderContext) { var steps = new List <BuildStep>(); var urlRoot = originalSourcePath.GetParent(); var fileStream = new FileStream(originalSourcePath.ToWindowsPath(), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); using (var recordedEffectCompile = new EffectLogStore(fileStream)) { recordedEffectCompile.LoadNewValues(); foreach (var entry in recordedEffectCompile.GetValues()) { var effectCompileRequest = entry.Key; var compilerParameters = new CompilerParameters(); effectCompileRequest.UsedParameters.CopyTo(compilerParameters); compilerParameters.Platform = context.GetGraphicsPlatform(); compilerParameters.Profile = context.GetGameSettingsAsset().DefaultGraphicsProfile; steps.Add(new CommandBuildStep(new EffectCompileCommand(context, urlRoot, effectCompileRequest.EffectName, compilerParameters, package))); } } Steps = steps; return(base.Execute(executeContext, builderContext)); }
public static BuildStep FromRequest(AssetCompilerContext context, Package package, UDirectory urlRoot, EffectCompileRequest effectCompileRequest) { var compilerParameters = new CompilerParameters(effectCompileRequest.UsedParameters); compilerParameters.EffectParameters.Platform = context.GetGraphicsPlatform(package); compilerParameters.EffectParameters.Profile = context.GetGameSettingsAsset().Get <RenderingSettings>(context.Platform).DefaultGraphicsProfile; compilerParameters.EffectParameters.ApplyCompilationMode(context.GetCompilationMode()); return(new CommandBuildStep(new EffectCompileCommand(context, urlRoot, effectCompileRequest.EffectName, compilerParameters, package))); }
protected override void Prepare(AssetCompilerContext context, AssetItem assetItem, string targetUrlInStorage, AssetCompilerResult result) { var asset = (ModelAsset)assetItem.Asset; // Get absolute path of asset source on disk var assetDirectory = assetItem.FullPath.GetParent(); var assetSource = UPath.Combine(assetDirectory, asset.Source); var gameSettingsAsset = context.GetGameSettingsAsset(); var renderingSettings = gameSettingsAsset.GetOrCreate <RenderingSettings>(); var allow32BitIndex = renderingSettings.DefaultGraphicsProfile >= GraphicsProfile.Level_9_2; var maxInputSlots = renderingSettings.DefaultGraphicsProfile >= GraphicsProfile.Level_10_1 ? 32 : 16; var allowUnsignedBlendIndices = context.GetGraphicsPlatform(assetItem.Package) != GraphicsPlatform.OpenGLES; var extension = asset.Source.GetFileExtension(); // Find skeleton asset, if any AssetItem skeleton = null; if (asset.Skeleton != null) { skeleton = assetItem.Package.FindAssetFromProxyObject(asset.Skeleton); } var importModelCommand = ImportModelCommand.Create(extension); if (importModelCommand == null) { result.Error($"No importer found for model extension '{extension}. The model '{assetSource}' can't be imported."); return; } importModelCommand.InputFilesGetter = () => GetInputFiles(assetItem); importModelCommand.Mode = ImportModelCommand.ExportMode.Model; importModelCommand.SourcePath = assetSource; importModelCommand.Location = targetUrlInStorage; importModelCommand.Allow32BitIndex = allow32BitIndex; importModelCommand.MaxInputSlots = maxInputSlots; importModelCommand.AllowUnsignedBlendIndices = allowUnsignedBlendIndices; importModelCommand.Materials = asset.Materials; importModelCommand.ScaleImport = asset.ScaleImport; importModelCommand.PivotPosition = asset.PivotPosition; importModelCommand.MergeMeshes = asset.MergeMeshes; importModelCommand.DeduplicateMaterials = asset.DeduplicateMaterials; importModelCommand.ModelModifiers = asset.Modifiers; if (skeleton != null) { importModelCommand.SkeletonUrl = skeleton.Location; // Note: skeleton override values importModelCommand.ScaleImport = ((SkeletonAsset)skeleton.Asset).ScaleImport; importModelCommand.PivotPosition = ((SkeletonAsset)skeleton.Asset).PivotPosition; } importModelCommand.Package = assetItem.Package; result.BuildSteps = new AssetBuildStep(assetItem); result.BuildSteps.Add(importModelCommand); }
protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, ModelAsset asset, AssetCompilerResult result) { if (!EnsureSourceExists(result, asset, assetAbsolutePath)) { return; } // Get absolute path of asset source on disk var assetDirectory = assetAbsolutePath.GetParent(); var assetSource = UPath.Combine(assetDirectory, asset.Source); var gameSettingsAsset = context.GetGameSettingsAsset(); var allow32BitIndex = gameSettingsAsset.DefaultGraphicsProfile >= GraphicsProfile.Level_9_2; var allowUnsignedBlendIndices = context.GetGraphicsPlatform() != GraphicsPlatform.OpenGLES; var extension = asset.Source.GetFileExtension(); if (ImportFbxCommand.IsSupportingExtensions(extension)) { result.BuildSteps = new AssetBuildStep(AssetItem) { new ImportFbxCommand { SourcePath = assetSource, Location = urlInStorage, Allow32BitIndex = allow32BitIndex, AllowUnsignedBlendIndices = allowUnsignedBlendIndices, Compact = asset.Compact, PreservedNodes = asset.PreservedNodes, Materials = asset.Materials, ScaleImport = asset.ScaleImport, }, }; } else if (ImportAssimpCommand.IsSupportingExtensions(extension)) { result.BuildSteps = new AssetBuildStep(AssetItem) { new ImportAssimpCommand { SourcePath = assetSource, Location = urlInStorage, Allow32BitIndex = allow32BitIndex, AllowUnsignedBlendIndices = allowUnsignedBlendIndices, Compact = asset.Compact, PreservedNodes = asset.PreservedNodes, Materials = asset.Materials, ScaleImport = asset.ScaleImport, }, }; } else { result.Error("No importer found for model extension '{0}. The model '{1}' can't be imported.", extension, assetSource); } }
protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, ModelAsset asset, AssetCompilerResult result) { if (!EnsureSourcesExist(result, asset, assetAbsolutePath)) { return; } // Get absolute path of asset source on disk var assetDirectory = assetAbsolutePath.GetParent(); var assetSource = UPath.Combine(assetDirectory, asset.Source); var gameSettingsAsset = context.GetGameSettingsAsset(); var renderingSettings = gameSettingsAsset.Get <RenderingSettings>(); var allow32BitIndex = renderingSettings.DefaultGraphicsProfile >= GraphicsProfile.Level_9_2; var allowUnsignedBlendIndices = context.GetGraphicsPlatform(AssetItem.Package) != GraphicsPlatform.OpenGLES; var extension = asset.Source.GetFileExtension(); // Find skeleton asset, if any AssetItem skeleton = null; if (asset.Skeleton != null) { skeleton = AssetItem.Package.FindAssetFromAttachedReference(asset.Skeleton); } var importModelCommand = ImportModelCommand.Create(extension); if (importModelCommand == null) { result.Error("No importer found for model extension '{0}. The model '{1}' can't be imported.", extension, assetSource); return; } importModelCommand.Mode = ImportModelCommand.ExportMode.Model; importModelCommand.SourcePath = assetSource; importModelCommand.Location = urlInStorage; importModelCommand.Allow32BitIndex = allow32BitIndex; importModelCommand.AllowUnsignedBlendIndices = allowUnsignedBlendIndices; importModelCommand.Materials = asset.Materials; importModelCommand.ScaleImport = asset.ScaleImport; importModelCommand.PivotPosition = asset.PivotPosition; importModelCommand.SkeletonUrl = skeleton?.Location; result.BuildSteps = new AssetBuildStep(AssetItem) { importModelCommand }; }
protected override void Compile(AssetCompilerContext context, AssetItem assetItem, string targetUrlInStorage, AssetCompilerResult result) { var asset = (SpriteStudioModelAsset)assetItem.Asset; var gameSettingsAsset = context.GetGameSettingsAsset(); var renderingSettings = gameSettingsAsset.Get <RenderingSettings>(context.Platform); var colorSpace = renderingSettings.ColorSpace; var cells = new List <SpriteStudioCell>(); var images = new List <UFile>(); if (!SpriteStudioXmlImport.ParseCellMaps(asset.Source, images, cells)) { throw new Exception("Failed to parse Sprite Studio cell textures."); } var texIndex = 0; asset.BuildTextures.Clear(); foreach (var texture in images) { var textureAsset = new TextureAsset { Id = Guid.Empty, // CAUTION: It is important to use an empty GUID here, as we don't want the command to be rebuilt (by default, a new asset is creating a new guid) Alpha = AlphaFormat.Auto, Format = TextureFormat.Color32Bits, GenerateMipmaps = true, PremultiplyAlpha = true, ColorSpace = TextureColorSpace.Auto, Hint = TextureHint.Color }; result.BuildSteps.Add( new TextureAssetCompiler.TextureConvertCommand( targetUrlInStorage + texIndex, new TextureConvertParameters(texture, textureAsset, context.Platform, context.GetGraphicsPlatform(assetItem.Package), renderingSettings.DefaultGraphicsProfile, gameSettingsAsset.Get <TextureSettings>().TextureQuality, colorSpace))); asset.BuildTextures.Add(targetUrlInStorage + texIndex); texIndex++; } result.BuildSteps.Add(new AssetBuildStep(assetItem) { new SpriteStudioModelAssetCommand(targetUrlInStorage, asset, colorSpace) }); }
protected override void Prepare(AssetCompilerContext context, AssetItem assetItem, string targetUrlInStorage, AssetCompilerResult result) { var asset = (SpriteSheetAsset)assetItem.Asset; var gameSettingsAsset = context.GetGameSettingsAsset(); var renderingSettings = gameSettingsAsset.GetOrCreate <RenderingSettings>(context.Platform); result.BuildSteps = new ListBuildStep(); var prereqSteps = new Queue <BuildStep>(); // create the registry containing the sprite assets texture index association var imageToTextureUrl = new Dictionary <SpriteInfo, string>(); var colorSpace = context.GetColorSpace(); // create and add import texture commands if (asset.Sprites != null && !asset.Packing.Enabled) { // sort sprites by referenced texture. var spriteByTextures = asset.Sprites.GroupBy(x => x.Source).ToArray(); for (int i = 0; i < spriteByTextures.Length; i++) { // skip the texture if the file is not valid. var textureFile = spriteByTextures[i].Key; if (!TextureFileIsValid(textureFile)) { continue; } var textureUrl = SpriteSheetAsset.BuildTextureUrl(assetItem.Location, i); var spriteAssetArray = spriteByTextures[i].ToArray(); foreach (var spriteAsset in spriteAssetArray) { imageToTextureUrl[spriteAsset] = textureUrl; } // create an texture asset. var textureAsset = new TextureAsset { Id = AssetId.Empty, // CAUTION: It is important to use an empty GUID here, as we don't want the command to be rebuilt (by default, a new asset is creating a new guid) IsStreamable = asset.IsStreamable && asset.Type != SpriteSheetType.UI, IsCompressed = asset.IsCompressed, GenerateMipmaps = asset.GenerateMipmaps, Type = new ColorTextureType { Alpha = asset.Alpha, PremultiplyAlpha = asset.PremultiplyAlpha, ColorKeyColor = asset.ColorKeyColor, ColorKeyEnabled = asset.ColorKeyEnabled, UseSRgbSampling = true, } }; // Get absolute path of asset source on disk var assetDirectory = assetItem.FullPath.GetParent(); var assetSource = UPath.Combine(assetDirectory, spriteAssetArray[0].Source); // add the texture build command. var textureConvertParameters = new TextureConvertParameters(assetSource, textureAsset, context.Platform, context.GetGraphicsPlatform(assetItem.Package), renderingSettings.DefaultGraphicsProfile, gameSettingsAsset.GetOrCreate <TextureSettings>().TextureQuality, colorSpace); var textureConvertCommand = new TextureAssetCompiler.TextureConvertCommand(textureUrl, textureConvertParameters, assetItem.Package); var assetBuildStep = new AssetBuildStep(new AssetItem(textureUrl, textureAsset)); assetBuildStep.Add(textureConvertCommand); prereqSteps.Enqueue(assetBuildStep); result.BuildSteps.Add(assetBuildStep); } } if (!result.HasErrors) { var parameters = new SpriteSheetParameters(asset, imageToTextureUrl, context.Platform, context.GetGraphicsPlatform(assetItem.Package), renderingSettings.DefaultGraphicsProfile, gameSettingsAsset.GetOrCreate <TextureSettings>().TextureQuality, colorSpace); var assetBuildStep = new AssetBuildStep(assetItem); assetBuildStep.Add(new SpriteSheetCommand(targetUrlInStorage, parameters, assetItem.Package)); result.BuildSteps.Add(assetBuildStep); while (prereqSteps.Count > 0) { var prereq = prereqSteps.Dequeue(); BuildStep.LinkBuildSteps(prereq, assetBuildStep); } } }
protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, TextureAsset asset, AssetCompilerResult result) { if (asset.Source == null) { result.Error("Source cannot be null for Texture Asset [{0}]", asset); return; } // Get absolute path of asset source on disk var assetDirectory = assetAbsolutePath.GetParent(); var assetSource = UPath.Combine(assetDirectory, asset.Source); result.BuildSteps = new ListBuildStep { new TextureConvertCommand(urlInStorage, new TextureConvertParameters(assetSource, asset, context.Platform, context.GetGraphicsPlatform(), context.GetGraphicsProfile(), context.GetTextureQuality(), false)) }; }
protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, TextureAsset asset, AssetCompilerResult result) { if (!EnsureSourceExists(result, asset, assetAbsolutePath)) { return; } // Get absolute path of asset source on disk var assetSource = GetAbsolutePath(assetAbsolutePath, asset.Source); var parameter = new TextureConvertParameters(assetSource, asset, context.Platform, context.GetGraphicsPlatform(), context.GetGraphicsProfile(), context.GetTextureQuality()); result.BuildSteps = new AssetBuildStep(AssetItem) { new TextureConvertCommand(urlInStorage, parameter) }; }
protected override void Prepare(AssetCompilerContext context, AssetItem assetItem, string targetUrlInStorage, AssetCompilerResult result) { var asset = (SpriteStudioModelAsset)assetItem.Asset; var gameSettingsAsset = context.GetGameSettingsAsset(); var renderingSettings = gameSettingsAsset.GetOrCreate <RenderingSettings>(context.Platform); var colorSpace = renderingSettings.ColorSpace; var cells = new List <SpriteStudioCell>(); var images = new List <UFile>(); if (!SpriteStudioXmlImport.ParseCellMaps(asset.Source, images, cells)) { throw new Exception("Failed to parse SpriteStudio cell textures."); } var texIndex = 0; asset.BuildTextures.Clear(); foreach (var texture in images) { var textureAsset = new TextureAsset { Id = AssetId.Empty, // CAUTION: It is important to use an empty GUID here, as we don't want the command to be rebuilt (by default, a new asset is creating a new guid) IsStreamable = false, IsCompressed = false, GenerateMipmaps = true, Type = new ColorTextureType { Alpha = AlphaFormat.Auto, PremultiplyAlpha = true, UseSRgbSampling = true, } }; var textureConvertParameters = new TextureConvertParameters(texture, textureAsset, context.Platform, context.GetGraphicsPlatform(assetItem.Package), renderingSettings.DefaultGraphicsProfile, gameSettingsAsset.GetOrCreate <TextureSettings>().TextureQuality, colorSpace); var textureConvertCommand = new TextureAssetCompiler.TextureConvertCommand(targetUrlInStorage + texIndex, textureConvertParameters, assetItem.Package); result.BuildSteps.Add(textureConvertCommand); asset.BuildTextures.Add(targetUrlInStorage + texIndex); texIndex++; } var step = new AssetBuildStep(assetItem); step.Add(new SpriteStudioModelAssetCommand(targetUrlInStorage, asset, colorSpace, assetItem.Package)); result.BuildSteps.Add(step); }
protected Dictionary <TImageInfo, int> CompileGroup(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, TGroupAsset asset, AssetCompilerResult result) { result.BuildSteps = new AssetBuildStep(AssetItem); // Evaluate if we need to use a separate the alpha texture SeparateAlphaTexture = TextureCommandHelper.ShouldSeparateAlpha(asset.Alpha, asset.Format, context.Platform, context.GetGraphicsProfile()); // create the registry containing the sprite assets texture index association var imageToTextureIndex = new Dictionary <TImageInfo, int>(); // create and add import texture commands if (asset.Images != null) { // sort sprites by referenced texture. var spriteByTextures = asset.Images.GroupBy(x => x.Source).ToArray(); for (int i = 0; i < spriteByTextures.Length; i++) { // skip the texture if the file is not valid. var textureFile = spriteByTextures[i].Key; if (!TextureFileIsValid(textureFile)) { continue; } var spriteAssetArray = spriteByTextures[i].ToArray(); foreach (var spriteAsset in spriteAssetArray) { imageToTextureIndex[spriteAsset] = i; } // create an texture asset. var textureAsset = new TextureAsset { Id = Guid.Empty, // CAUTION: It is important to use an empty GUID here, as we don't want the command to be rebuilt (by default, a new asset is creating a new guid) Alpha = asset.Alpha, Format = asset.Format, GenerateMipmaps = asset.GenerateMipmaps, PremultiplyAlpha = asset.PremultiplyAlpha, ColorKeyColor = asset.ColorKeyColor, ColorKeyEnabled = asset.ColorKeyEnabled, }; // Get absolute path of asset source on disk var assetDirectory = assetAbsolutePath.GetParent(); var assetSource = UPath.Combine(assetDirectory, spriteAssetArray[0].Source); // add the texture build command. result.BuildSteps.Add( new TextureAssetCompiler.TextureConvertCommand( ImageGroupAsset.BuildTextureUrl(urlInStorage, i), new TextureConvertParameters(assetSource, textureAsset, context.Platform, context.GetGraphicsPlatform(), context.GetGraphicsProfile(), context.GetTextureQuality(), SeparateAlphaTexture))); } result.BuildSteps.Add(new WaitBuildStep()); // wait the textures to be imported } return(imageToTextureIndex); }
protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, TextureAsset asset, AssetCompilerResult result) { if (!EnsureSourcesExist(result, asset, assetAbsolutePath)) { return; } // Get absolute path of asset source on disk var assetSource = GetAbsolutePath(assetAbsolutePath, asset.Source); var gameSettingsAsset = context.GetGameSettingsAsset(); var colorSpace = context.GetColorSpace(); var parameter = new TextureConvertParameters(assetSource, asset, context.Platform, context.GetGraphicsPlatform(AssetItem.Package), gameSettingsAsset.Get <RenderingSettings>(context.Platform).DefaultGraphicsProfile, gameSettingsAsset.Get <TextureSettings>().TextureQuality, colorSpace); result.BuildSteps = new AssetBuildStep(AssetItem) { new TextureConvertCommand(urlInStorage, parameter) }; }
protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, SpriteSheetAsset asset, AssetCompilerResult result) { var gameSettingsAsset = context.GetGameSettingsAsset(); result.BuildSteps = new AssetBuildStep(AssetItem); // create the registry containing the sprite assets texture index association var imageToTextureUrl = new Dictionary <SpriteInfo, string>(); var colorSpace = context.GetColorSpace(); // create and add import texture commands if (asset.Sprites != null && !asset.Packing.Enabled) { // sort sprites by referenced texture. var spriteByTextures = asset.Sprites.GroupBy(x => x.Source).ToArray(); for (int i = 0; i < spriteByTextures.Length; i++) { // skip the texture if the file is not valid. var textureFile = spriteByTextures[i].Key; if (!TextureFileIsValid(textureFile)) { continue; } var spriteAssetArray = spriteByTextures[i].ToArray(); foreach (var spriteAsset in spriteAssetArray) { imageToTextureUrl[spriteAsset] = SpriteSheetAsset.BuildTextureUrl(urlInStorage, i); } // create an texture asset. var textureAsset = new TextureAsset { Id = Guid.Empty, // CAUTION: It is important to use an empty GUID here, as we don't want the command to be rebuilt (by default, a new asset is creating a new guid) Alpha = asset.Alpha, Format = asset.Format, GenerateMipmaps = asset.GenerateMipmaps, PremultiplyAlpha = asset.PremultiplyAlpha, ColorKeyColor = asset.ColorKeyColor, ColorKeyEnabled = asset.ColorKeyEnabled, ColorSpace = asset.ColorSpace, Hint = TextureHint.Color }; // Get absolute path of asset source on disk var assetDirectory = assetAbsolutePath.GetParent(); var assetSource = UPath.Combine(assetDirectory, spriteAssetArray[0].Source); // add the texture build command. result.BuildSteps.Add( new TextureAssetCompiler.TextureConvertCommand( SpriteSheetAsset.BuildTextureUrl(urlInStorage, i), new TextureConvertParameters(assetSource, textureAsset, context.Platform, context.GetGraphicsPlatform(), gameSettingsAsset.DefaultGraphicsProfile, gameSettingsAsset.TextureQuality, colorSpace))); } result.BuildSteps.Add(new WaitBuildStep()); // wait the textures to be imported } if (!result.HasErrors) { var parameters = new SpriteSheetParameters(asset, imageToTextureUrl, context.Platform, context.GetGraphicsPlatform(), gameSettingsAsset.DefaultGraphicsProfile, gameSettingsAsset.TextureQuality, colorSpace); result.BuildSteps.Add(new SpriteSheetCommand(urlInStorage, parameters)); } }
protected override void Prepare(AssetCompilerContext context, AssetItem assetItem, string targetUrlInStorage, AssetCompilerResult result) { var asset = (TextureAsset)assetItem.Asset; // Get absolute path of asset source on disk var assetSource = GetAbsolutePath(assetItem, asset.Source); var gameSettingsAsset = context.GetGameSettingsAsset(); var colorSpace = context.GetColorSpace(); var parameter = new TextureConvertParameters(assetSource, asset, context.Platform, context.GetGraphicsPlatform(assetItem.Package), gameSettingsAsset.GetOrCreate <RenderingSettings>(context.Platform).DefaultGraphicsProfile, gameSettingsAsset.GetOrCreate <TextureSettings>().TextureQuality, colorSpace); result.BuildSteps = new AssetBuildStep(assetItem); result.BuildSteps.Add(new TextureConvertCommand(targetUrlInStorage, parameter, assetItem.Package)); }
protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, ModelAsset asset, AssetCompilerResult result) { if (asset.Source == null) { result.Error("Source cannot be null for Texture Asset [{0}]", asset); return; } // Get absolute path of asset source on disk var assetDirectory = assetAbsolutePath.GetParent(); var assetSource = UPath.Combine(assetDirectory, asset.Source); var allow32BitIndex = context.GetGraphicsProfile() >= GraphicsProfile.Level_9_2; var allowUnsignedBlendIndices = context.GetGraphicsPlatform() != GraphicsPlatform.OpenGLES; var extension = asset.Source.GetFileExtension(); // compute material and lighting configuration dictionaries here because some null reference can occur var materials = new Dictionary <string, Tuple <Guid, string> >(); var lightings = new Dictionary <string, Tuple <Guid, string> >(); foreach (var meshParam in asset.MeshParameters) { if (meshParam.Value.Material != null) { materials.Add(meshParam.Key, new Tuple <Guid, string>(meshParam.Value.Material.Id, meshParam.Value.Material.Location)); } // Transform AssetReference to Tuple<Guid,UFile> as AssetReference or ContentReference is not serializable (to generate the command hash) // TODO: temporary while the LightingParameters is a Member of MeshMaterialParameter class // TODO: should be passed directly in the Parameters of the mesh - no extra case is required if (meshParam.Value.LightingParameters != null) { lightings.Add(meshParam.Key, new Tuple <Guid, string>(meshParam.Value.LightingParameters.Id, meshParam.Value.LightingParameters.Location)); } } if (ImportFbxCommand.IsSupportingExtensions(extension)) { result.BuildSteps = new ListBuildStep { new ImportFbxCommand { SourcePath = assetSource, Location = urlInStorage, Allow32BitIndex = allow32BitIndex, AllowUnsignedBlendIndices = allowUnsignedBlendIndices, Compact = asset.Compact, PreservedNodes = asset.PreservedNodes, Materials = materials, Lightings = lightings, // TODO: remove when lighting parameters will be behind a key Parameters = asset.MeshParameters.ToDictionary(pair => pair.Key, pair => pair.Value.Parameters), ViewDirectionForTransparentZSort = asset.ViewDirectionForTransparentZSort.HasValue ? asset.ViewDirectionForTransparentZSort.Value : -Vector3.UnitZ, }, new WaitBuildStep(), }; } else if (ImportAssimpCommand.IsSupportingExtensions(extension)) { result.BuildSteps = new ListBuildStep { new ImportAssimpCommand { SourcePath = assetSource, Location = urlInStorage, Allow32BitIndex = allow32BitIndex, AllowUnsignedBlendIndices = allowUnsignedBlendIndices, Compact = asset.Compact, PreservedNodes = asset.PreservedNodes, Materials = materials, Lightings = lightings, // TODO: remove when lighting parameters will be behind a key Parameters = asset.MeshParameters.ToDictionary(pair => pair.Key, pair => pair.Value.Parameters), }, new WaitBuildStep(), }; } else { result.Error("No importer found for model extension '{0}. The model '{1}' can't be imported.", extension, assetSource); } }
protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, TGroupAsset asset, AssetCompilerResult result) { result.BuildSteps = new ListBuildStep(); // Evaluate if we need to use a separate the alpha texture SeparateAlphaTexture = context.Platform == PlatformType.Android && asset.Alpha != AlphaFormat.None && asset.Format == TextureFormat.Compressed; // create the registry containing the sprite assets texture index association SpriteToTextureIndex = new Dictionary <TImageInfo, int>(); // create and add import texture commands if (asset.Images != null) { // return compilation error if one or more of the sprite does not have a valid texture var noSourceAsset = asset.Images.FirstOrDefault(x => !TextureFileIsValid(x.Source)); if (noSourceAsset != null) { result.Error("The texture of image '{0}' either does not exist or is invalid", noSourceAsset.Name); return; } // sort sprites by referenced texture. var spriteByTextures = asset.Images.GroupBy(x => x.Source).ToArray(); for (int i = 0; i < spriteByTextures.Length; i++) { var spriteAssetArray = spriteByTextures[i].ToArray(); foreach (var spriteAsset in spriteAssetArray) { SpriteToTextureIndex[spriteAsset] = i; } // create an texture asset. var textureAsset = new TextureAsset { Id = Guid.Empty, // CAUTION: It is important to use an empty GUID here, as we don't want the command to be rebuilt (by default, a new asset is creating a new guid) Alpha = asset.Alpha, Format = asset.Format, GenerateMipmaps = asset.GenerateMipmaps, PremultiplyAlpha = asset.PremultiplyAlpha, ColorKeyColor = asset.ColorKeyColor, ColorKeyEnabled = asset.ColorKeyEnabled, }; // Get absolute path of asset source on disk var assetDirectory = assetAbsolutePath.GetParent(); var assetSource = UPath.Combine(assetDirectory, spriteAssetArray[0].Source); // add the texture build command. result.BuildSteps.Add( new TextureAssetCompiler.TextureConvertCommand( ImageGroupAsset.BuildTextureUrl(urlInStorage, i), new TextureConvertParameters(assetSource, textureAsset, context.Platform, context.GetGraphicsPlatform(), context.GetGraphicsProfile(), context.GetTextureQuality(), SeparateAlphaTexture))); } result.BuildSteps.Add(new WaitBuildStep()); // wait the textures to be imported } }