Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Writing a component that extends a generic abstract class

Discussion in 'Scripting' started by default_team, Dec 24, 2020.

  1. default_team

    default_team

    Joined:
    Dec 1, 2018
    Posts:
    21
    I'm trying to script a component that extends from a generic abstract class.

    For example:

    Code (CSharp):
    1. [AddComponentMenu("MyComponents/MyComponent")]
    2. public class MyComponent : MyBaseComponent<Object>
    3. {
    4. }
    5.  
    6. public abstract class MyBaseComponent<T> : MonoBehaviour {
    7. }

    But it's not available as a component in the inspector. What am I doing wrong?
     
  2. default_team

    default_team

    Joined:
    Dec 1, 2018
    Posts:
    21
    I was able to sort this out. The issue is due to my class type not matching the file name and not due to the generics as I initially thought.