Adding New Content

Adding New Content

 

Monogame uses a content pipeline to turn source assets (i.e. images, audio,etc.) into runtime formats that might require different formats specific to each platform (i.e. Windows, Android, Playstation).

Here are the steps to add a new texture to one of our exercises.

Step 1) Download MonoGame pipeline executable. (try this and change the extension .zzz to .zip)

Step 2) Unzip the folder where you have permission and double click pipeline.exe. You should see this:

 

Step 3) Create a new project. Select File->New and create a .mgcb file with any name that you will remember. This project file stores your settings so that if you use this tool again, everything is saved as you left it.

Step 4) Add an existing item.

add_existing_item

Step 5) Select the texture that you would like to convert. You can try this one as a test.

Step 6)  Select the gear icon and your image will convert from an image to an .xnb file.gear_icon

Step 7) The output file will be saved as an xnb file in the bin directory. The “bin” directory is in the same directory as where you created the .mgcb file (you can double check the location of the bin directory by clicking on the top level tree object in the pipeline application and finding the Output Folder property which is just below the tree. Click on the property and you will see a button with three dots. Click on that and you will see the path.)

Step 8) Add the .xnb file to the Content directory in Visual Studio by right clicking on the content directory and selecting Add->Existing Item. (note: if you navigate to the bin directory and don’t see anything, select “All Files (*.*)” from the select box above the “Add” button.)

add_existing_item_vs

Step 9) Finally, left click on the .xnb file in Visual Studio. Next edit the property Copy to Output Director and change it to “Copy if Newer”.

copy_if_newer

Step 10) Load the texture with the content manager. Your code may look similar to this:

_contentManager.Load<Texture2D>(“Graphics\\smileTexture”);

Note that you do not include the .xnb file extension. Use the texture as defined in the Monogame Documentation  or in earlier exercises that you did in this course (i.e. such as the texture exercise).