March 31st, 2011, 04:22 PM
Dynamic method adding / calling
I'm working on a game editor for the XNA framework and I've gotten most things working just fine but I would like the functionality to add scripts to my game objects and have those run at runtime. These scripts would just be simple predefined methods in C# and I would like to call the method based on what scripts were attached in the editor. I am thinking this would be easiest to do on the editor end by just loading the current scripts available and selecting them based on their string name.
Then, in the game runtime the methods would somehow be loaded into the class so they can be used. I have looked into the topic a bit and reflection seems like an option but I want to know what would be the best option here. As this code will by dynamically loaded into specific classes of the base GameObject class, dynamically loading a method could be quite taxing and I would have to know if this dynamic loading could only be done once and a reference to the method could be stored via a delegate perhaps?
Let me know if I am being unclear.
This is .NET 4.0.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.