Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by UniteMage · May 21, 2011 at 02:44 AM · classinheritance

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.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Peter G · May 21, 2011 at 01:31 PM 0
Share

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.

3 Replies

· Add your reply
  • Sort: 
avatar image
3

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · May 21, 2011 at 03:26 AM 0
Share

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.

avatar image
-1

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

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TowerOfBricks · May 23, 2011 at 02:52 PM 0
Share

Sorry to downvote you, but this is not an answer, it should have been posted as a comment.

avatar image DaveA · May 23, 2011 at 03:08 PM 0
Share

yeah, you should comment, and when you like the answer, hit the checkmark there to the left

avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges