- Home /
How to use Inheritance and Constructors in Unity
I have a difficult time trying to implement inheritance and constructors in unity. Are there any examples that use this ideas?
I am asking this because I have a hard time scripting in unity while I don't feel this when I code for my cs classes. I don't know why but it seems really different. One example is that I end up creating bunch of little scripts for different actions and the amount of script and script referencing becomes absurd. This is why I thought inheritance, abstract classes, POLYMORPHISM might help.
For constructors, I don't understand how are you supposed to use this? Constructors basically creates a new object. However, usually in unity, you have all the gameobjects spawned in the scene or it is Instantiate().
So it will help if examples are provided!! :p
Also, on the same topic on organization of scripts, what is: MODULARIZATION & DEPENDENCY INVERSION mentioned in this post
thank you :D
Answer by meat5000 · Mar 16, 2015 at 12:37 AM
http://unity3d.com/learn/tutorials/modules/beginner/scripting
Scroll down to 'Intermediate', #6 and #7
Not sure this will help if you are a seasoned programmer...
Thanks but I actually searched "unity inheritance" on google and watched those videos. He explained what it is but did not give examples on how it can be used in unity... I'm still a coding newbie so I don't know how to use it :p
Thanks again though