Hi
By 100% of code I mean that I have folder with prefabs and I don’t want to atach all prefabs manualy to script variable (making array and choose one of them) like in unity example Unity - Manual: Instantiating Prefabs at run time. Is it possible to tell unity that I want to add spcecific prefab from specific assets folder but purely in JS code ?
Hello,
Yes, its possible by using Resources.Load() .
With this function I’ll not have any problem with web appliaction ? Does unity attach and compress it all to webplayer file even if the prefabs aren’t used in any scene at start ?
Anything in the Resources folder will be packed into the build whether it’s used or not, since Unity has no way to tell which ones are actually used. While attaching them all to an array can be a bit tedious, it’s what provides Unity the information of which prefabs are actually used in a scene.