Convert Image and Sound Files to XNB files - c#

I created a XNA Game Library Project that loads several sound and image files. But for the project to run, I need to convert these to XNB files. I am wondering, how do you go about doing that? Thanks!

The XNA Content Pipeline takes care of much of that for you. If you are using the XNA Game Studio, importing many types of content files will automatically hook up the right pipeline (which you can then edit).

Related

Is there any way to load the Vuforia dataset in Unity streaming assets folder on demand or separately to reduce the main apk size?

I am developing an AR application in Unity using Vuforia's model tracking. So I generated a model target using the Model Target Generator, exported it and imported the unity package file in my Unity project. I imported the .dat file in the Streaming Assets folder in Unity Assets.
The problem is the apk size has increased a lot due to this file. As the streaming assets directory is read only, is there any other way to load the .dat file on demand? The apk size might become too big, if the dataset size are increased in future.
Addressables and apk expansion file method did not help.
This is definitely possible and there are recommendations documented in the library of Vuforia Engine: https://library.vuforia.com/unity-extension/building-large-vuforia-engine-apps-unity/.

Could not load assets as non content files on Android?

I have included a SpriteFont asset and an mp3 asset in my MonoGame cross platform project, the strange thing is that the the game compiles and runs fine on the iOS simulator but whenever I try to build the game on Android I get warnings like this for the files in the bin directory and in the content directory
/Users/edward/Library/Mobile Documents/com~apple~CloudDocs/apps/Xamarin/Android/Radiant/Android/Content/lights.mp3:
Warning XA0101: #(Content) build action is not supported (XA0101) (Radiant.Droid)
And when I try and run the game, I get a
Could not load score asset as a non content file
I have tried many things such as changing the build actions of various files but nothing has worked.
This could be an issue of upper case and lower case file names. I've run into this issue before.
If it's not that, you can extract the Android *.apk file like a *.zip file to see what files are actually in there. This can seriously help on figuring out why files aren't being loaded with android.
To Extract
Create a copy of your *.apk file, so that you're not modifying the original.
Change the file extension too *.zip.
Now right click and extract like any other *.zip file.
You can then go in and explore the folder hierarchy to see what files are being included.
Check your Asset folder to see if the file you're looking for is there or not.
Hope this helps.
Are you using the monogame content builder or are you trying to load them in directly as .mp3 .png or whatever?
If you aren't using the content builder everything has to be .xnb on android.

Why Xna doesn't load .fx files

I'm learning Xna, and I have some trouble with loading non .xnb file formats.
I don't know why, but Xna searches only for .xnb files.
Here is my code:
Effect simpleColorEffect;
simpleColorEffect = Content.Load<Effect>("SimpleColor");
I saw some solutions for this, but they didn't work.
How can i solve this?
I would thank you any advices.
Put specific file into Content folder and make sure that content processor for that file is set to Effect - XNA framework.

C# + XNA: Location of Sprite Folder and Sprites after Compile

I am trying to program an automatic Resource Loader for my project and so it is going well. But I am stuck on the loading of the sprites. I used this for checking the file exists
if (File.Exists(contentManager.RootDirectory + "/Sprites/" + spriteName + ".png"))
However it never finds the file, even though the file exists in the Content of the project. I have checked the folders and found that the .pngs are replaced by .xnb files. So I tried changing the file extension and then was given an error in the Sprite Load function
return contentManager.Load<Texture2D>(assetName);
It only happens if I change it from being a typical image file (png, bmp, etc). Can someone explain why this is the problem and how I can get around this? I have had no experience in the xna file extensions and can not find the answers I need. What I want is to load a new image into the project providing it exists in the Content Directory after compile
While on the topic, will the Sounds and Music be effected by the Compiler?
When you use a content project, the resources are imported, processed and write to disk again as xnb files.
If you want to dynamically load resources you have to compile files on the fly through the content builder or avoid using the content project.
Microsoft provides examples like this to load content dynamically: http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_2
if you want to distribute the application, the runtime xna is not enoigh, you need full xna framework and visual studio installed to work.
if you want the original files in the content project, you have to change their "copy to output folder" property to "copy always", and realize that the compiled results will be at "project folder\bin\debug\content"

Loading sound file into monogame

I'm trying to load sound into my game. I downloaded an .mp3 sound (a second long) and tried to load it both as Song and as SoundEffect, but it didn't work, so I tried loading the same sound but as .wav and I was able to load it as a SoundEffect. The problem is that the sound that is coming out sounds like static noise.
I looked a bit into this and found out I need to load sounds as .xnb files, so I downloaded "XNAContentCompiler" project and tried to compile the sounds causing a PInvokeStackImbalance error.
So I found this thread:
http://xboxforums.create.msdn.com/forums/p/65519/65519.aspx
Saying I can ignore this and continue.
The xnb file fails to be created when I try to convert the .wav files, saying it is 24-bit audio and I may only use 8 to 16 bit.
So I tried to compile the .mp3 file and it succeed, creating a 1k file that I still cannot load not as a Song and not as SoundEffect.
I'm now completely lost on this and can no longer understand what I need to try to load and what is a different problem completely, and I would love some explanations.
Audio files, as any content file, needs to be converted using the XNA Content Pipeline, it's easier if you use a Visual Studio 2010 version with XNA installed in it to convert your contents, so you can copy that .xnb file in your Monogame project.
I think you already know that you have to change its properies to "Copy always" and "Content" to use it in Monogame.
If your problem is the bit resolution, you can always use an audio converter, you can find them online, too.
Anyway, it's better if you use .mp3 as Song and .wav as SoundEffect.

Categories