|
Hello, I'm trying to call a function from a class of an object. I have the Object but no clue to access the right Component. A little Example: Thats the Method I want to Call from this: I cant call it with GetComponent() because it should work with any other class as well. When I call the Method, I know the Method is there because every class from Effect has this one, but I dont know the concrete Name of the Class. Hope you can Help.
(comments are locked)
|
Are you saying that all of your effects inherit from If you're having trouble understanding the above, you may want to read up on polymorphism, which is one of the most important principles in object-oriented programming. For starters, here's an MSDN guide on override methods. And, finally, if you can't get that working, there is always "_effect.GetComponents() to get a full list of them. You could write ApplyEffect() as a virtual method in Effect, and have each effect class override it." Thats weird, thought I already tried this. Tried around with GetComponents() and overriding, must have missed the right combination of both with some other things I tried. ;) Works pretty well, thanks for the answer. I also will keep SendMessage in mind for the future. =)
Jun 23 '12 at 07:46 PM
Huma
(comments are locked)
|

Ok - so the effect is related to the game object _effect how?
I have an Object for each xyzEffect and an Object for each Item. If I want to create a new Potion I drag and drop the effects I want to assign to it in the Inspector.