[C#] Changing parent variable without constructor

Started by stripe103, August 20, 2012, 02:45:43 pm

Previous topic - Next topic


August 23, 2012, 10:13:15 am #20 Last Edit: August 23, 2012, 10:27:52 am by stripe103
Yeh, I know you should use properties, but with Unity, public variables is just as easily accessed, so you might as well use them instead, but I'll try.

Oh wait... when using System.Activator.CreateInstance, is the constructor triggered? If so then this whole conversation was unnessecary :)


August 28, 2012, 07:59:35 am #21 Last Edit: August 28, 2012, 08:02:50 am by stripe103

Once again, I need help with the system I'm currently trying to get to work..
For the last problem, I managed to fix it using virtual methods(which I tried before too, but couldn't get to work),
now there is just one thing left to fix.

Because I use child classes for each Event Command, it doesn't load the correct class,
and loads the information into EventCommand instead of EventMessage in this case, so it uses
those methods instead.

I have a simple way of saving the class type ID, that I use for listing all commands. I just need some simple way to use the
methods in the child classes instead of using the EventCommand ones, that doesn't do anything.

I thought of doing something like this

cmd.Update() as eventCommands[cmd.classTypeID].GetType()

Of course, none of those worked, it was just what I came up with that maybe could work..
So basically, the command in cmd is of type EventCommand, but I want it to get the type "eventCommands[cmd.classTypeID].GetType()"
and use that to run the right class method.