I am adding a script named “Part” to a part of a 3D model at runtime like this:
private var _Part;
var obj=Parts.transform.Find(partName);
_Part=obj.gameObject;
_Part.AddComponent("Part");
_Part.GetComponent(Part).init(this);
In the “Part” script I have this:
function init(parentRef){
this.AddComponent("BoxCollider");
}
but it fails (I think) because “this” doesn’t reference the _Part game object i.e. the game object it is a component of. How can I reference the game object?
The error I get is:
MissingMethodException: Method not found: ‘Part.AddComponent’.