Search Unity

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.