0

Hello,


I'm creating a game editor and I'm at the current stage that I would like the ability to attach scripts to objects (by selecting the string of the method name to be called). That would be saved into the object's scripts to load / run array. That shouldn't be too difficult, the part I'm having trouble with is finding a method to dynamically call functions at runtime based on what script they need to run. Keep in mind this "script" is just C# code.

I need to run the scripts efficiently at game runtime and I can't have complicated lookups to the functions. Is there some way I can do this? I'm thinking delegates / reflection but I'm not sure how to implement any of it.

There's not really any code yet for this specifically but I'll provide whatever is deemed necessary for a reply.

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Momerath
0

Although it would be cool if they are generated at runtime, I'm not going to bother with that yet. The are going to be predefined in a scripts folder.

Edited by BigTito89: n/a

0

The easiest way is to create a delegate. Then use this delegate to create an array of your 'scripts' and use that to call the methods.

You can also use reflection to find the methods and call them, but that takes more work :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.