I’m trying to use pragma strict to prepare a file for the iphone. In the file I have
a GameObject and I want to reference a function in another script. I have a function which allows the user to load an object dynamically then attach a script to the object. In this case they load a cow and then attach cowScript.js
This doesn’t work. The error is that initialize() is not a member of Component.
function loadObject(otype:String,oname:String){
//instantiates a cow from resources load first and names it oname
GameObject.Find("cow").AddComponent(otype+"Script");
GameObject.Find("cow").AddComponent(otype+"Script").initialize();
}
loadObject("cow","bessie");
I’m not sure where the problem is or how to fix it. But I do want to have it so the user can name their object and attach different scripts to it. Is there a workaround that would preserve the dynamic script idea.
Thanks,