- Home /
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?
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. $$anonymous$$aybe 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.
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.
"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:$$anonymous$$aterial;
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;
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.
Your answer
Follow this Question
Related Questions
Errors with shaders/materials on newer iOS devices 1 Answer
Buttons take time to be fully charged at startup 0 Answers
navmesh loads really long 0 Answers
Videoclip codec for mobile devices 0 Answers
iOS Strange Render Lag 1 Answer