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

2D game - Really Huge Scrolling Background

Discussion in '2D' started by PeterGost, Mar 27, 2021.

  1. PeterGost

    PeterGost

    Joined:
    Jan 27, 2020
    Posts:
    18
    I am working on a 2d game, the main object is Train driving around. It will be on a really, really, really huge background. (hard to say how huge image will be, but let's assume that the average mobile phone would struggle to load the whole image into memory)

    So, I am wondering will it be efficient if I put a background .png image on a 3D object mesh filter(plane), and attach my background as a material?

    Is this the correct approach? Or should I do something else?
     
    Last edited: Mar 27, 2021
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,503
    You may want to fragment your large image into smaller images that you load when the train approaches an area and might soon see a new fragment. This would allow you to selectively load from disk only the parts that need to be seen. Unload when the train exits an area and doesn't need an old fragment in memory.

    It could be MeshRenderer and Filter, SpriteRenderer, whatever.
     
    Last edited: Mar 27, 2021
  3. PeterGost

    PeterGost

    Joined:
    Jan 27, 2020
    Posts:
    18

    Okay, understand what you are saying. Do I need to do that programmatically or will Unity do that for me, if I have smaller fragments?
    It is more of a question does Unity cares if the image is not in camera view? I am new at Unity, so please forgive if my questions.
     
  4. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,503
    You need to do so programmatically.
    Kind of. It depends on the concern. An asset that's loaded will be in memory even if not in view. It will be culled so there's no rendering cost. Many, many things outside of view may add to culling costs.