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 Views

Discussion in '2D' started by Martin_Gonzalez, Jan 18, 2019.

  1. Martin_Gonzalez

    Martin_Gonzalez

    Joined:
    Mar 25, 2012
    Posts:
    361
    Hi all!

    I have been working with 2d applications for a while and at this moment, in the company where I work, we are entrusted to make a serious view navigator.
    The way I've been creating screen has always been the same and I'm intrigued if there is any better way to do it.

    The way I create things:
    - A unique canvas.
    - Views are prefabs.
    - Depending on the configuration, Views are instantiated at the beginning and kept in memory, other views are instantiated on runtime (I am aware that it is expensive)
    - View are GameObjects with all it's content inside. And a root view script (Generally using MVP model-view-presenter). All views are inside the unique canvas.
    - Only one scene
    - Prefabs are instantiated with prefab-reference or Resources.Load
    - Depending on the configuration, views are destroyed or hide
    - Views have a lifecycle controlled by a navigator
    - We have a tool to automize view creation

    My question really is how views would be better structured.

    Perhaps having a Canvas for each view is better.
    Perhaps using scenes instead of prefabs and overlay them.

    Thanks for your anwers!
     
    Last edited: Jan 19, 2019
  2. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    Don't know enough about speeds, but consider using multiple inactive gameobjects rather than loading/unloading them via resources. (in no way am i saying this is faster, but it might be)
     
  3. Martin_Gonzalez

    Martin_Gonzalez

    Joined:
    Mar 25, 2012
    Posts:
    361
    I would like to know if there is a better way of structuring views, not about loading or unloading.