The issue is that the AddObject method returns a Component. You need to tell the compiler that your T is actually a type of Component.
Attach a generic constraint to your method, to ensure that your T
s are Component
s
protected void AttachComponent<T>() where T : Component
{
// Your code.
}