共用方式為


Game Content Project

Describes a project type (nested within a standard XNA Game Studio 3.0 project) designed to store all content for a game application.

Overview

A game content project uses the XNA Framework Content Pipeline to build game content (models, textures, sounds, and so forth). You add content items to this project as project items. Item properties define how each content item is imported and processed as part of the build operation. Game content projects are built automatically whenever their parent projects are built. In addition, their configurations and platforms are the same as their parent projects.

Game content projects have a References node that lists the assemblies and projects containing the importers and processors currently used in a Content Pipeline build. Individual content items are listed and their properties are accessible using the Properties window. You can use either the standard Add New Item dialog box or the Add Existing Item dialog box to add items to a game content project.

Warning

The Build Action property of any project item moved into the nested content project is set automatically to Compile. This value persists even if the same item later is moved out of the nested content project.

Content in Game Libraries

Classes and methods in game libraries may rely on specific content, such as textures and shaders, to perform their game-related functions. For this purpose, game libraries provide their own content subfolders that can contain those assets to ensure they will be available.

When a game project includes reference to a game library, a copy of the output of the game library is included in the output directory of the game project. In this way, both the game library's referenced assembly and its associated content are available at run time.

All content in the game content subproject of a successfully built game library will be compiled through the content pipeline, just as the code of a game library is stored in its compiled form. This permits game projects that reference these reusable elements of the game library to build more quickly.

Content within a game library may be referenced directly by the game project. There is no requirement that the classes or methods of the game library must reference the content in a game library.

Project Designer Properties

These properties are not available to game content projects. All changeable properties are in the Content Pipeline Properties, described below.

Content Pipeline Properties

The content project has additional properties (other than those available in the Project Designer tabs) that specify operating parameters for the XNA Framework Content Pipeline. To access these properties, select the Content node in Solution Explorer, then from the View menu, select Properties Window (or type the function key F4).

Content Root Directory

Specifies the name of the subdirectory that will hold the final output files of pipeline content generated from this project folder. This may be useful if your game project has multiple content projects and you wish to keep the output of each in different subdirectories.

Code-Only Builds

By manually editing a .csproj file, you can build your game project without also building the nested content project. If you are using XNA Game Studio, open the related .csproj file, and add the following property:

      <SkipNestedContentBuild>true</SkipNestedContentBuild>
    

If you are building from the command-line, use the following command to skip the nested content project:

Msbuild /p:SkipNestedContentBuild=true WindowsGame1.csproj

For more information on using MSBuild with project files, see How To: Edit Project Files and Visual Studio Integration (MSBuild).

In addition, you can build only the nested content project from the command line by invoking MSBuild directly on the .contentproj file of your nested content project.

See Also

Adding Game Content Projects
Managing Game Assets
Using XNA Game Studio