Public file for configuration

I’d like to have a .xml file that can be configured during run-time to make changes in my application. Currently, I have not found a way in the build process to specify a file as being available for editing by a user.

As a little background, I’m currently creating a menu system for some slot games that is being ported over to Unity. Because of legal requirements and client specifications rapidly changing, I’d like to be able to edit this menu via a .xml file, so there wouldn’t be a need to recompile the entire project, as the menu is generated at run-time. In most applications, this is just a matter of having an app.config file or something similar, but I haven’t seen the equivalent for Unity. Any pointers?

1 Answer

1

You can use normal .NET code to open the file for reading, parse it (JSON is a good format, or xml), and create the menu based on the contents. The file itself would need to be somewhere besides the Assets folder - the project root is a decent place. You can use a post build function to copy the file to the build target folder using normal file IO operations.

Relevant documentation:

UnityEngine.JsonUtility

System.IO.File class

PostProcessBuildAttribute

So what is it you need here exactly? Does your required objects field represent actual, specific instances of required objects, or do you just want their types? If it's just the types, then you should probably serialize the AssemblyQualifiedName string