Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Feb 27, 2015 at 02:18 AM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by jpthek9 · Feb 26, 2015 at 11:13 PM · inheritancemonobehaviourfixedupdate

Calling Unity functions in an inherited class?

My base class inherits from MonoBehaviour and the inherited class inherits from the base class. Is it possible to call methods like FixedUpdate in the inherited class? I.e.

 Class BaseClass : MonoBehavior{}
 
 class InheritedClass : BaseClass{
     void FixedUpdate()
     {
         print("Is this possible?");
     }
 }
Comment
Add comment · Show 2
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 meat5000 ♦ · Feb 26, 2015 at 11:33 PM 0
Share

Have you tried it? $$anonymous$$aybe you should try it.

avatar image spiceboy9994 · Feb 26, 2015 at 11:54 PM 0
Share

$$anonymous$$onobehavior classes are quite special... not sure you can do that. As a personal suggestion, whenever I "need to inherit" from $$anonymous$$onoBehavior, I create a main $$anonymous$$onoBehavior wrapper class, and I add the rest of the component as custom classes. Then I use the $$anonymous$$onoBehavior wrapper just a like a master control for the rest of the components.

Regards

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by meat5000 · Feb 27, 2015 at 12:20 AM

If something Inherits from MonoBehaviour it has all MonoBehaviour gubbings and whatever you add in. What would be the point of inheritance otherwise?

 using UnityEngine;
 using System.Collections;
 
 public class SomeBase : MonoBehaviour {
 
     public float test1 = 0.0f;
 }


 using UnityEngine;
 using System.Collections;
 
 public class SomeInherited : SomeBase{
     void FixedUpdate()
     {
         print("Is this possible?");
     }
 }


![alt text][1]


monoinheritance.jpg (93.1 kB)
Comment
Add comment · Show 3 · 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 meat5000 ♦ · Feb 27, 2015 at 12:23 AM 0
Share

It probably took you longer to write this question than it would have taken you to try it.

avatar image jpthek9 · Feb 27, 2015 at 02:16 AM 0
Share

Silly mistake on my part - caught it and forgot to take down the question. I didn't create an instance of SomeInherited lol. Thanks for the answer anyways.

avatar image meat5000 ♦ · Feb 27, 2015 at 02:17 AM 0
Share

No problem :)

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

C# Conception - Hide inherited members and functions 1 Answer

What is the signature of Awake() and Start() 1 Answer

[C#] Using Static Create() methods with inheritance and Monobehaviours? 3 Answers

How to make different types of Objects in database? 1 Answer

MonoBehaviour Inheritance, Singletons and Generics 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