- Home /
How to "include" an inherited C# Class into the file?
What are the mechanics to "include" an inherited C# Class into the file? Like C++ that uses the pragma #include.
Does it have to be attached to the same GameObject?
Should the inherited Class be included (cut and paste) into the same file even though many other files may incorporate the same inherited class?
Could the Class simply lie in the scripts folder and Unity will include the file into the other automatically?
Thanks CSDG.
Unity will automatically include all scripts in your build. It does not try and deter$$anonymous$$e which ones are used and which are not like it does with other assets so as long as it is in your project folder, you can expect it in your final build.
Answer by DaveA · May 21, 2011 at 03:07 AM
The last one. If that doesn't work, make a Plugins folder and put it in there. If it's a namespace you may want to use a 'using' statement, but you shouldn't need to.
Right, you can even put the base class inside any script file as long as you don't want to attach it to a GameObject. inherited classes can be attached as long as they are in seperate files. But to keep a better overview you should place even the base-class in a seperate file ;). $$anonymous$$ake sure you create a public class
.
Answer by UniteMage · May 21, 2011 at 03:32 AM
OK - Thanks Dave
Adding files is like MAGIC - Unity includes (attaches) references to other files that are not attached to GameObjects. WOW!
Thanks again. CSDG
Sorry to downvote you, but this is not an answer, it should have been posted as a comment.
yeah, you should comment, and when you like the answer, hit the checkmark there to the left
Answer by UniteMage · May 21, 2011 at 10:20 PM
Thanks Peter G
Unity will automatically include all scripts in your build. It does not try and determine which ones are used and which are not like it does with other assets so as long as it is in your project folder, you can expect it in your final build.
This bit of information is important. One day I uploaded many script examples into a Unity project in order to experiment. Unity was bleeding through other apps and doing weird stuff.
I will remember to clean my scripts folder once i have finished with the project. Is there any diagnostics or statistical software to determine how the project is functioning?
Thanks again CSDG
Your answer
Follow this Question
Related Questions
Inheritance best solution to handle *many* instances of a class with unique values? 1 Answer
How to set different classes at runtime 2 Answers
Putting a Child Class into a List of Parent Type and then casting it back to a Child 0 Answers
Can I call a class's method which inherit monobehaviour by a normal class? 0 Answers
The type 'myclass' does not have a visible constructor that matches the argument list 1 Answer