# Generic T type

**URL:** <https://discussions.unity.com/t/generic-t-type/69628>\
**Category:** Questions & Answers\
**Created:** [April 28, 2013, 10:24am UTC](https://discussions.unity.com/t/generic-t-type/69628 "2013-04-28T10:24:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NinjaSu](https://avatars.discourse-cdn.com/v4/letter/n/a88e4f/32.png) [@NinjaSu](https://discussions.unity.com/u/NinjaSu)\
**Post date:** [April 28, 2013, 10:24am UTC](https://discussions.unity.com/t/generic-t-type/69628/1 "2013-04-28T10:24:49Z")

</div>

So I have a class

```
public class Alpha<T> : MonoBehaviour {

}

```

However, Unity doesn’t let me attach the script to the a GameObject, for it thinks the script name has changed.

---

<div class="post-metadata">

**Author:** ![kmeboe](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@kmeboe](https://discussions.unity.com/u/kmeboe)\
**Post date:** [April 28, 2013, 5:29pm UTC](https://discussions.unity.com/t/generic-t-type/69628/3 "2013-04-28T17:29:08Z")

</div>

Although you can’t attach a generic class (as mentioned above), if you inherit from your class and give it a specialization, you can then attach this subclass to an object. So like this:

```
// GenericClass.cs
// This class can't be attached.
public class GenericClass <T> : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}

// SpecializedSubclass.cs
// But this one can.
public class SpecializedSubclass : GenericClass<int> {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}

```

---

<div class="post-metadata">

**Author:** ![whydoidoit](https://avatars.discourse-cdn.com/v4/letter/w/90db22/32.png) [@whydoidoit](https://discussions.unity.com/u/whydoidoit)\
**Post date:** [April 28, 2013, 10:27am UTC](https://discussions.unity.com/t/generic-t-type/69628/2 "2013-04-28T10:27:03Z")

</div>

Yep, you can’t attach that because Unity has no idea what the generic parameter would be. You can’t attach behaviours which are generic at the top level because there is no way of specifying T.
