Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Storing screens in multiple scenes, how to deal with EventSystem?

Discussion in 'UGUI & TextMesh Pro' started by apocriva, Mar 10, 2015.

  1. apocriva

    apocriva

    Joined:
    Nov 3, 2011
    Posts:
    25
    One of the things I've done in the past that I found has been a very useful workflow has been to store screens in separate scenes, and loading those scenes together at runtime.

    The issue that I run into right off the bat with the new Unity UI system is the EventSystem object that gets created alongside a UI Canvas to handle input. Because each screen scene contains one of these objects, I have to deal with them in some fashion. Ideally, I expect that I would want to maintain a single instance of EventSystem, and simply disable/destroy any additional EventSystem objects that get loaded in when loading a screen.

    Is having screens split into separate screens someone else has experience with? How have you dealt with these EventSystem objects?
     
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    I take it you are referring to nested scenes in U5? or LoadLevelAdditive?
    There should only even be one EventSystem in a scene ever. However since it has a singleton at it's heart it shouldn't (don't quote me on that) cause an issue.
    I would have thought UT had covered this situation with U5, any ideas @phil-Unity

    The other solution is to have one primary scene with all the UI and then transition each on or off as required. Not ideal but workable, so long as you use a single spritesheet for all UI assets there shouldn't be a performance hit.
     
  3. apocriva

    apocriva

    Joined:
    Nov 3, 2011
    Posts:
    25
    Oh my... I missed the SceneManager-related stuff when looking over the new features for Unity 5! Looks really helpful.

    Either way, the situation I was looking at, each screen is defined in a scene by itself. For testing purposes, it's necessary to have the EventSystem object present in each scene. This allows me to test UI by hitting Play with one of those screen-scenes loaded. The problem is that when you LoadLevelAdditive a bunch of them together, each scene comes with its own EventSystem.

    If the multi-scene editing stuff is in place now, though, there's probably a much clearer way forward, because I could define the EventSystem object in a "main" scene and load another scene together with that for testing.

    ...and upon further digging, I don't see any evidence to suggest that multi-scene editing is possible right now.
     
    Last edited: Mar 10, 2015
  4. apocriva

    apocriva

    Joined:
    Nov 3, 2011
    Posts:
    25
    If people don't generally use multiple scenes to store screens in UI, how are they storing them? It seems problematic to store them all together in one scene, because then multiple people can't work on separate screens at once, and it seems problematic to store them in prefabs, because then it's impossible to store widgets in their own prefabs and have them change globally to update style.
     
  5. ranza

    ranza

    Joined:
    May 8, 2009
    Posts:
    44
    I'd like to know this as well.
    It would be very helpful to have let say Level1 in one scene together with some scene one related UI, but load generic UI from different scene. Does anyone have a solution for this?
     
  6. MrPhil

    MrPhil

    Joined:
    Sep 22, 2010
    Posts:
    40
    This is exactly what I was wondering and I'm sad to see no answer. :(
     
  7. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    375
    I have a check in the Awake of our base ui panel class that spawns the event system if its not present. That way the scenes are clean for actual use but still work for testing.
     
    MrPhil likes this.