XNA 内容项目中内容的通配符? [英] Wildcard for content in an XNA content project?
问题描述
我有一个 XNA 3.1 内容项目 (.contentproj),其中包含以下内容:
I have an XNA 3.1 content project (.contentproj) with the following:
<ItemGroup>
<Compile Include="tilesB000N800.BMP">
<Name>B000N800</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
<Compile Include="tilesB000N801.BMP">
<Name>B000N801</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
(... and so on ...)
</ItemGroup>
我想做的是能够指定一个通配符,以便编译 tiles*.bmp
- 这样我就不必不断重新同步内容项目当我在tiles"目录中添加和删除纹理时.
What I'd like to do is be able to specify a wildcard so that tiles*.bmp
gets compiled instead - so that I don't have to keep re-synchronising the content project when I add and remove textures from the "tiles" directory.
有人知道怎么做吗?
理想情况下,解决方案会忽略tiles"下隐藏的.svn"目录.并且内容项目将继续在 Visual Studio 中运行.
Ideally the solution would ignore the hidden ".svn" directory, under "tiles". And also the content project would continue to work in Visual Studio.
推荐答案
我发现 Shawn Hargreaves 的一篇博文描述了如何为 XNA 1.0 做到这一点:
I found a blog post by Shawn Hargreaves that describes how to do this for XNA 1.0:
基于此,这是我在 XNA 3.1 上所做的工作(并且不会导致那些奇怪的 _0 出现):
Based on that, here is what I did which works with XNA 3.1 (and doesn't cause those weird _0 to appear):
创建一个单独的tiles.proj"文件,内容如下:
Create a separate "tiles.proj" file with the following content:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<ItemGroup>
<WildcardContent Include="tiles***.BMP" Exclude="tiles.svn*">
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</WildcardContent>
</ItemGroup>
<Target Name="BeforeBuild">
<CreateItem Include="@(WildcardContent)" AdditionalMetadata="Name=%(FileName)">
<Output TaskParameter="Include" ItemName="Compile" />
</CreateItem>
</Target>
</Project>
在原始的.contentproj"文件中,在</Project>
之前,添加:
And in the original ".contentproj" file, right before </Project>
, add:
<Import Project="tiles.proj" />
这篇关于XNA 内容项目中内容的通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!