- Home /
dynamically creating MenuItem via an xml File
Hello,
We are working on the portage of our internal library inside Unity, and we have to create dynamically MenuItem.
We know how create MenuItem from the attribute [MenuItem("MyMenuName/MyItem"] attached to a static void function, but what we want is to instantiate it from an XML file:
... ...
Is there a way to do this?
Thank you for your help
Answer by Mike 3 · Oct 05, 2010 at 02:57 PM
As far as I know, it's not possible to load a MenuItem any other way. The way Unity does it is to look for the attribute, then add straight to the menu - after that, there's no way to add any other ones manually
Thank you, I think Perhaps we can use System.Reflection.Emit for creating the attribute but for the moment, I have no Idea about a way to add a static method directly to the assembly.
Answer by Adam Rademacher · Oct 05, 2010 at 02:55 PM
If you're using C# this is actually relatively simple. You can include the System.XML namespace and use it to load your XML. I recommend using the Resources folder to house your XML as it makes it very easy to load the data into data.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Load/Save script 0 Answers
How To Switch A XmlNodeList To A String 1 Answer
Declaring XML Namespace at Runtime 1 Answer
Saving new children/subchildren in XML 0 Answers