|
I have a game object that's created at runtime, I've attached a script to it after creating it, that script holds an instantiation of an object should something happen.... because this game object is created at runtime, and the script is attached after it's creation, I can't access the inspector to set the prefab... So I'm trying to add it in code... something like this: this script is attached to the object that's waiting for the condition to create the prefab:
And later, inside the update (){ is this:::
}
(comments are locked)
|
|
The GetComponent function returns a component, not a prefab of a game object. Yet you assign it into PS_top_ordered which is a game object. I can't even believe the Javascript compiler allows you to do that! Use C# :) so how do I set the variable PS_top_ordered to the prefab "PS_top_Ordered" which is sitting in my Project?
Dec 23 '10 at 04:12 PM
dissidently
If I do it like this, it tells me I'm trying to make the variable into a string>>>> var PS_top_ordered : GameObject; PS_top_ordered = ("PS_top_Ordered");
Dec 23 '10 at 04:14 PM
dissidently
Instead of assigning PS_top_ordered in your script, since your script should be attached to a game object, slide (click->drag) your PREFAB named PS_top_ordered into the property in the inspector, then you can instantiate at will! :)
Dec 23 '10 at 04:21 PM
taoa
I can't do that. the Script is nested. Sits on a game object that's created at runtime, from a prefab. The script is added to the instantiation of the prefab at game start using "addcomponent" which works, (pulling the script from the inspector to attach to the newly created "parent" prefab) but getting this second layer deeper, and pulling a prefab from the inspector doesn't?
Dec 23 '10 at 04:47 PM
dissidently
The Javascript compiler doesn't allow it, if you use #pragma strict.
Dec 23 '10 at 05:12 PM
Eric5h5
(comments are locked)
|
