system
December 31, 2010, 12:38pm
1
So I have no problem instantiating Objects normally until I came across this today:
I want to instantiate a game object from its saved model sanem:String, but I get the error cant convert STring to Object.
var h:GameObject=Instantiate(gameplaySceneManagerScript.clueNodeArray[x].model.name);
How would I go about instantiating from a string like this?
p.S>.there IS a prefab with that name ready to be instanced.
Jessy
December 31, 2010, 3:41pm
3
No. Instantiate is not for instantiating strings. It is for putting objects into the Hierarchy. You can't see a string in the Hierarchy. A string is not a Game Object. Instantiate the prefab itself, which is a Unity Object.
If you need to load things based on name, then use the Resources folder and corresponding methods .
poncho
December 31, 2010, 3:31pm
2
if that object exist on your scene, you can try
Instantiate(Gameobject.Find(gameplaySceneManagerScript.clueNodeArray[x].model.name));
hope it works
good luck