0

I want to create a scripting system for my game engine. I will have a button that creates a class from template that derives from the class "Script". This class will only have one method "Update" that will be called in the "GameObject" class (I am considering having an internal class that handles the scripts). Also the scripts will all be created in the designated GameObject folder.

I have found many posts about Activator but I don't really understand it and I can't find anything specific for my scenario anyways.

Prateek Gupta
  • 2,422
  • 2
  • 16
  • 30
Cuvin Stefan
  • 43
  • 1
  • 1
  • 6
  • I don't understand what you want to do. Do you just wand to generate the source code files, do you also want to create instances from these classes at runtime. Maybe describe your scenario. "_that will be called in the "GameObject" class […]_" What do you mean by that? – v01pe May 25 '20 at 13:03
  • Sorry for my poot explination. I'll try again. I want to create instances of those clases at runtime (they are all derived from the abstract class "Script"). I got it to work with normal classes, but i am having trouble with the ones that are derived from Script. I also want to add those isntances to a LinkedList of type Script. – Cuvin Stefan May 25 '20 at 13:27

1 Answers1

0

How to load a class from .cs file and use it in code describes how to load a file and run a method in it dynamically. Combine with Directory.GetFiles to list .cs files and you should have a solution.

JonasH
  • 28,608
  • 2
  • 10
  • 23