GameObject.name to call script name?

Hi guys, im implementing pragma strict and now need to get rid of my dynamic scripting (?)

Anyways my old script did this.

var FObject : GameObject;

//FObject is instantiated within the script first, from resources
function Update () {
    FObject.GetComponent(FObject.name).FWild = 1;
}

The script name of the object is the same as the object itself, and therefore wanted to reference it’s script by just calling the object’s name. So how can i solve this in a way which is acceptable with pragma strict?

Error: BCE0019

Thanks!!

I think you need to cast the component to the type of the component first.


var component  : TypeOfComponent  = FObject.GetComponent(FObject.name) as TypeOfComponent;
component.FWild  = 1;