|
|
2 月之前 | |
|---|---|---|
| .. | ||
| .config | 2 月之前 | |
| .vscode | 2 月之前 | |
| Core | 2 月之前 | |
| Platforms | 2 月之前 | |
| README.md | 2 月之前 | |
| SamplesContentBuilder.sln | 2 月之前 | |
| windows.bat | 2 月之前 | |
This project demonstrates how to build and load content assets using MonoGame 3.8.* with the modern .NET SDK project system. It serves as a comprehensive example of content pipeline usage for various asset types including textures, fonts, models, audio, and effects.
Game1.cs) and common project references (SamplesContentBuilder.Core.csproj)Platforms/Windows/SamplesContentBuilder.Windows.csproj)Platforms/DesktopGL/SamplesContentBuilder.DesktopGL.csproj)Platforms/iOS/SamplesContentBuilder.iOS.csproj)Platforms/Android/SamplesContentBuilder.Android.csproj)The project includes sample assets of various types:
The project uses a centralized content approach with platform-specific build configurations:
All raw content assets (textures, fonts, models, audio, etc.) are stored once in the Content/ directory structure:
Content/Effects/ - Shader filesContent/Fonts/ - Font definitionsContent/Models/ - 3D modelsContent/Music/ - Audio filesContent/Textures/ - Images and spritesContent/bonus/ - Additional sample texturesEach platform has its own Content.mgcb file that references the same source assets but builds with platform-specific settings:
Content/Content-Windows.mgcb - DirectX optimized contentContent/Content-DesktopGL.mgcb - OpenGL optimized contentContent/Content-iOS.mgcb - iOS optimized contentContent/Content-Android.mgcb - Android optimized contentSamplesContentBuilder.slnSelect one of the available tasks:
build-content-windows - Build Windows content assets onlybuild-content-desktopgl - Build DesktopGL content assets onlybuild-content-ios - Build iOS content assets onlybuild-content-android - Build Android content assets onlybuild-windows - Build Windows platform (legacy layout)build-desktopgl - Build DesktopGL platform (legacy layout)build-platform-windows - Build Windows platform (modern layout)build-platform-desktopgl - Build DesktopGL platform (modern layout)build-platform-ios - Build iOS platformbuild-platform-android - Build Android platformclean-content - Clean content build outputsclean-all - Clean all build outputsTo run and debug:
Build content for specific platforms:
dotnet mgcb -@ Content/Content-Windows.mgcb
dotnet mgcb -@ Content/Content-DesktopGL.mgcb
dotnet mgcb -@ Content/Content-iOS.mgcb
dotnet mgcb -@ Content/Content-Android.mgcb
Build specific platform projects:
# Platform projects
dotnet build Platforms/Windows/SamplesContentBuilder.Windows.csproj
dotnet build Platforms/DesktopGL/SamplesContentBuilder.DesktopGL.csproj
dotnet build Platforms/iOS/SamplesContentBuilder.iOS.csproj
dotnet build Platforms/Android/SamplesContentBuilder.Android.csproj
dotnet build Core/SamplesContentBuilder.Core.csproj
Run:
# Platform projects
dotnet run --project Platforms/Windows
dotnet run --project Platforms/DesktopGL
dotnet run --project Platforms/iOS
dotnet run --project Platforms/Android
dotnet run --project Core
The project uses MonoGame's Content Builder (MGCB) to process raw assets into optimized .xnb files. Content is centralized in the Content/ directory but built to platform-specific output directories:
Content/bin/Windows/Content/bin/DesktopGL/Content/bin/iOS/Content/bin/Android/This approach eliminates content duplication while maintaining platform-specific optimizations. Each platform references the same source assets but builds them with platform-appropriate settings and outputs them to isolated directories.
Content processing is handled automatically through the MonoGame.Content.Builder.Task NuGet package during build.
This project has been modernized from legacy XNA/MonoGame format to use:
This sample demonstrates: