Components using Generics

I have a class using generics:


public class ProjectileWeapon<T> : WeaponBase where T : ProjectileEffect

When I try to drag the script in the Editor I get an error saying the class name doesn't match the file name.

When I try to use AddComponent I don't get any error but it returns 'null':

ProjectileWeapon<PlasmaProjectile> weapon = gameObject.AddComponent<ProjectileWeapon<PlasmaProjectile>>();
print("weapon = " +;

Weapon is 'null' and I get an Object reference exception in the print statement. Am I doing something wrong or is Components using generics just not supported?

I found this page, is this the same problem?

Yes that is the same problem. What you are trying to do is not possible. What you should instead do is make new Monobehaviour scripts for each class that inherits from ProjectileEffect, like PlasmaProjectile.

public class PlasmaProjectileWeapon : ProjectileWeapon<PlasmaProjectile>


Unity3D could have done something about this, but I dont think it is a priority.