Is there any way to extract a C# function definition from an XML file at run-time.
At run-time, the game loads information from XML files and initializes the scene and UI based on the info from the files. Our team is using external tools to design a UI layout and the tool stores the layout in an XML file including custom defined C# function to run when a button is pressed. I need to figure out a way to load and/or evaluate the code from the XML file generated by the external tool.
I am using the Unity Pro license so I have access to all MonoDevelop functionality.
Microsoft’s C# does not yet have a “compiler as a service”, i.e simple ability to compile code from code (It’s coming soon but isn’t available yet). However Mono’s implementation of C# does have that, which is part of why Unity uses C# to begin with.
Unfortunately when Unity builds the C# VS project for you, they don’t use the mono runtime. I don’t know what happens on the MonoDevelop side as I don’t use it. Either way, the relevant namespaces may not be exposed to the project.
Best thing to do is read about Mono’s “compiler as a service” capabilities and try to add it as a manual reference to the project and see what happens. It is very likely that the namespace will be available at runtime (Since Unity use it internally) just not exposed to the project.