Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Prevent an editor-assigned texture from loading into memory, load it on-demand later?

Discussion in 'Scripting' started by andcuriouser, Jul 18, 2013.

  1. andcuriouser

    andcuriouser

    Joined:
    Jul 17, 2013
    Posts:
    10
    I tried posting this to Answers, but never got a response.

    I've built a storybook-type app that moves between a number of fairly large textures (many of them 2k). I had originally programmed it so that anything far away from the current "page" is deactivated, and only activated once the user gets close to them. I had thought that this would keep the majority out of textures out of memory. Obviously, I was wrong--everything stays in memory from the time the app starts. This has turned out to be fine for any devices with > 512mb of RAM. Unfortunately, if I test on anything with 512mb or lower, it's an instant crash.

    Everything was built in the editor--none of the textures are loaded programmatically (which would have made this a lot easier). Essentially, what I need to do is prevent every single GameObject from loading its texture when the game starts, and then tell each GameObject to load it's editor-assigned texture at a certain time. Is there a sensible way of doing this?
     
  2. tonyd

    tonyd

    Joined:
    Jun 2, 2009
    Posts:
    1,224
  3. andcuriouser

    andcuriouser

    Joined:
    Jul 17, 2013
    Posts:
    10
    I guess that means I need to strip the textures from every GameObject in the editor? I was hoping there was a solution that wouldn't require me to redo everything, but it was probably overoptimistic.