Adding properties to default gameobject or transform

I want to do something like this:

function OnCollisionEnter (collisionInfo:Collision) {
    collisionInfo.transform.originalParent = collisionInfo.transform.parent = transform;
    collisionInfo.transform.parent = transform;
}

function OnCollisionExit (collisionInfo:Collision) {
    collisionInfo.transform.parent = collisionInfo.transform.originalParent;
}

Sure I could create a list / array / dictionary / whatever and keep track locally. But I rather do it on the object so I can use that info elsewhere easily.

Any hints? Probably it will be something simple thinking in some other way! :P

You can do everything that you just listed by default. I'm not sure what you are specifically suggesting, maybe the `checkTag()`. Just change the tag of the game object in the inspector and either use `component.tag == "string"` or `gameObject.CompareTag("string")`

or maybe you are referring to `originalParent`. You cannot add functionality to Unity's built-in classes and you really shouldn't inherit from most of them either (the exception being MonoBehavior). You could instead have an essentially empty script that keeps track of this, then use `GetComponent()` to set it.

//playerInfo.js
var originalParent : Transform;

function Start () {
     originalParent = transform.parent;
}

Then use `GetComponent()` to access that information when you collide with the object.

Here's the closest I could get to what I needed. Call this class `PlayerInfo.js` (thanks to Peter insight):

var originalParent : Transform;

function OnCollisionEnter (collisionInfo:Collision) {
    PlayerInfo info = collisionInfo.gameObject.GetComponent("PlayerInfo");
    if (!info) info = collisionInfo.gameObject.AddComponent("PlayerInfo");

    info.originalParent = collisionInfo.transform.parent;
    collisionInfo.transform.parent = transform;
}

function OnCollisionExit (collisionInfo:Collision) {
    PlayerInfo info = collisionInfo.gameObject.GetComponent("PlayerInfo");
    if (!info) info = collisionInfo.gameObject.AddComponent("PlayerInfo");

    collisionInfo.transform.parent = info.originalParent;
}

Of course there are ways to make this better, but this is descriptive enough. This way there's no need to create a new class and, above all, no need to manually add it anywhere. It will be added as needed.