0

Im still learning and looking for anyone who can help me out how this works :

For example Unity has FixedUpdate() and Update() most likely ran from a Thread orsomething that tells when to call that method. How does it work that if you inherit your class from Monobehaviour all you've got to do is write void FixedUpdate() { //Code }

In Short :

How do I make a Parent Class like Monobehaviour that calls a certain method but also be able to send arguments to that method to all classes that inherit from "Parent Class"

31eee384
  • 2,748
  • 2
  • 18
  • 27
Dylan Wijnen
  • 219
  • 3
  • 13
  • 2
    Unity is weird because they are using reflection to find methods by name, and not making use of inheritance. If you're writing your own thing outside of Unity, don't use it for a model for how to think. You'll want to research inheritance in C#. – zstewart Sep 22 '15 at 22:14
  • So how exactly would "using reflection to find methods by name" work storing all objects in a list and doing a call on the method ? – Dylan Wijnen Sep 22 '15 at 22:19
  • 1
    Are you working in Unity, or is this just C# and your prior experience is in Unity? – zstewart Sep 22 '15 at 22:27
  • @zstewart this is just in C# i've just taken unity as an example – Dylan Wijnen Sep 22 '15 at 22:34
  • 1
    Unity does not do it the way you would do it anywhere else. Don't use Unity as an example of how the rest of C# works. Unity is not actually using inheritance when they call your [Fixed]Update method. What you want is to define a base class with a virtual version of the method you want to call, and then override that method in the child classes. – zstewart Sep 22 '15 at 22:36
  • Ok yh, I've tried. Basicly i created a "Parent Class" wich creates a graphics component it also starts a thread for the drawing i want to do. but since i inherit the class it will start 2 threads and try to create 2 graphics components and leads into errors – Dylan Wijnen Sep 22 '15 at 22:44
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/90375/discussion-between-zstewart-and-dylan-wijnen). – zstewart Sep 22 '15 at 22:45
  • OP was actually looking for help with general inheritance, specifially [calling the base constructor](http://stackoverflow.com/questions/12051/calling-the-base-constructor-in-c-sharp) – zstewart Sep 22 '15 at 23:04

0 Answers0