x


Loading disabled GameObject assets

There are a lot of questions on here about loading but I haven't found one that answers my question.

I have a lot of disabled GameObjects in my scene that are enabled when the player moves towards them. On iOS this causes a lag when the assets from that GameObject are loaded. Is there a way I can load the assets at the start of the scene?

Also the same thing happens when I switch the material of a GameObject at runtime. Is there a way to load an asset that isn't used on anything by default and is only ever applied dynamically?

more ▼

asked Aug 10 '12 at 08:28 PM

lozzaaa gravatar image

lozzaaa
1 1 2

What do you mean by "when the assets are loaded"? It seems like you should have gameobjects that are already made(containing most of the things they need) and disabled, that way there is no loading during the game since it gets loaded when the scene get loaded. Maybe you could specify a little more.

As for the last portion about having an asset that isnt on anything, you can have a single script that holds things, for instance your material. Its not used on an object, but when you need it you can just grab it from your variable on that script.

Aug 11 '12 at 02:21 AM OperationDogBird

That is exactly what I am doing but it doesn't load when the scene is loaded. For instance I have a particle effect that is called when you start the game that makes it lag horribly the first time it is played but from then on it is absolutely fine.

I didn't mean it isn't on anything i meant it is only applied to a mesh during the game so when the game loads it isn't applied to the mesh. This causes the game to lag when i switch the objects material for the first time again but from then on it's fine. It's clearly a loading issue.

Aug 11 '12 at 09:53 AM lozzaaa

"For instance I have a particle effect that is called when you start the game" Does this mean you are manually loading it using Resources.Load() ?

You can have a script on an empty object in the scene that holds things like.. materials, particle effects, etc. That way they load with the scene and no manual loading is required.

Global.js

public var material:Material;
public var particles:ParticleEmitter;

then when you want to change the material, say

//First set a reference to the Global script

renderer.material=global.material;
Aug 11 '12 at 07:47 PM OperationDogBird

With particle effects on mobile this behavior is normal. The lagging on the first activation of the effect. What I did to correct this is play all the effects for that particular level somewhere far away in game space just as the level loads so the lag isn't noticeable to the player. From then on it will be fine.

Aug 12 '12 at 04:28 AM AnXgotta
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1969
x820
x298
x216
x196

asked: Aug 10 '12 at 08:28 PM

Seen: 353 times

Last Updated: Aug 12 '12 at 04:28 AM