- Home /
How to load only assets that needed?
As I work on live wallpaper, I'm trying to use minimum possible memory. Objects in the scene are instantiating and destroying this way:
public GameObject prefabObject; // is set in Editor
private GameObject instanceObject;
....
private void ShowObject()
{
if (this.instanceObject == null)
{
this.instanceObject = (GameObject)Instantiate(this.prefabObject);
}
}
private void HideObject()
{
if (this.instanceObject != null)
{
Destroy(this.instanceObject);
this.instanceObject = null;
}
}
Also, there are some HD-versions of textures, which I show and hide the same way - by referencing Material in Editor and instantiating it at runtime when needed;
Although it seems not enough, as RAM used by application on a real device is still about 80-90 MBs, just as it was when all resources were instantiated simultaneously. Expected value must be about a half of it. Also, as all resources still always loading (when only few of them is really used), it obviously takes longer time to load.
How can I load only those assets that I really going to show, but still have strict references to resources to load it when needed?
Answer by KiraSensei · Apr 24, 2014 at 11:51 AM
I think you need to use THIS. You may also need THIS and THIS to use it correctly and optimize your memory load.
Yup, already found though, and even implemented. :) As always, right query in google is a half of solution...
Your answer
Follow this Question
Related Questions
Can I buy the asset of easy water, replace their textures with my own, and still sell my game? 3 Answers
File exist, path is null but isn't C# 0 Answers
Need to check for presence of a prefab instance at a particular location. 0 Answers
Resources.LoadAll() still loading prefabs twice in Unity 5.5.1 0 Answers
Change assets after build? 0 Answers