How to load a Unity GameObject during runtime?
Hey everyone, I am creating an editor for a game and I want to allow a designer to make new spells. What I am trying to achieve is that a designer will download a Unity particle system, save it on the computer and will give the game full path to it. Then the game should load the object and use it as a particle for a new spell.
I need to be able to load a Unity GameObject (particle system) during runtime from a folder. I know that Unity has Resources folder for that. But it only works if I put the object file to the Resources folder through Unity before buidling the game. But I need the designer to be able to download GameObjects long after the game is built and then put them in. Is there any way to do that? The code for Resources file is :
public void LoadParticle(string name)
{
GameObject myParticle;
myParticle = (GameObject)Resources.Load(texturePath + "/" + name, typeof(GameObject));
if (myParticle == null)
{
print("Cant find particle");
cont = false;
}
else
{
particle = myParticle;
cont = true;
}
}
(cont is just a variable that I use to determine if I should keep creating a new spell or not)
I also tried it with Asset Bundles, but I don’t know how to use Asset Bundles when I only want to download the file from the computer (local file system) not from the server. Asset bundles work perfectly in Debug but not when I build and run it (It tries to connect to some server instead). Thank you so much
Your answer
Follow this Question
Related Questions
load .unity3d assetbundle from resource folder 0 Answers
Buy Unity Assets 0 Answers
Assigning Asset Bundle in Script 2 Answers
Asset Bundle not compatible between different unity versions 1 Answer
How to remove inside of assetbundle camera in unity? 0 Answers