public void CacheTexture(string texturePath) { string cacheFolder = Path.Combine(FileSrv.BasePath, "cache"); string spritesFolder = Path.Combine(cacheFolder, "sprites"); string tempFolder = Path.Combine(cacheFolder, "_temp"); Directory.CreateDirectory(spritesFolder); Directory.CreateDirectory(tempFolder); var pm = new MonoGame.Framework.Content.Pipeline.Builder.PipelineManager(spritesFolder, tempFolder, @"Path\_temp"); pm.Profile = GraphicsProfile.HiDef; pm.CompressContent = false; pm.Platform = TargetPlatform.Windows; var builtContent = pm.BuildContent(texturePath); var processedContent = pm.ProcessContent(builtContent); //Console.WriteLine($"{texturePath} => {processedContent.GetType().Name}"); }
public void RecompileEffect(object sender, FileSystemEventArgs e) { if (e.Name == FileName) { MonoGame.Framework.Content.Pipeline.Builder.PipelineManager PM = new MonoGame.Framework.Content.Pipeline.Builder.PipelineManager(Path, Path + "\\tempBin", "Path\\tempBin"); bool Worked = false; while (!Worked) { try { var BuiltContent = PM.BuildContent(Path + "\\" + FileName); var ProcessedContent = PM.ProcessContent(BuiltContent); OnEffectChanged?.Invoke(new Effect(Device, ((CompiledEffectContent)ProcessedContent).GetEffectCode())); Worked = true; File.Delete(Path + "\\tempBin\\" + FileName.TrimEnd(".fx".ToArray()) + ".xnb"); } catch (InvalidContentException E) { Common.Debug.DebugConsole?.Write("CompilerException"); Common.Debug.DebugConsole?.Write(E.Message); Worked = true; } }