Search Unity

Prefab UI environment scene workflow suggestions

Discussion in 'Prefabs' started by 5argon, Dec 19, 2018.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    After shifting to design each small pieces of UI in the prefab mode, I have found some workflow issues :

    - The default UI Environment is rarely a good default : It is a naked Canvas without CanvasScaler. That means its coordinate sizing is exactly what your Game view currently is. If my editor layout makes the game view small, the coordinate boundary is also small.

    -- The game view should be for viewing what's "outside" as you design your object, not something that could affect the "inside" in any way. Currently the Canvas component is exactly a weird, unintended link from game view to design view.

    - For the game to be responsive in positioning most people used CanvasScaler, so coordinate are fixed. I can make my UI environment to match my CanvasScaler. But if the game used different setup of CanvasScaler in each place, I have to make a separated environment for each.

    -- It is very deep in the settings to switch the environment to the one I want to use for a particular UI.

    --- I think of docking the settings window, but changing the environment does not update the envionment instantly until I exit - enter prefab mode again.

    --- Solution : When clicking on the "Canvas (Environment)", the inspector might offer a box to select other environment to switch on the fly. (Register multiple of them in the settings window)
    --- Solution 2 : Make the root level default UI environment not greyed out, but able to use CanvasScaler as you wish. These settings should be persistent, remembered across exit and enter to different UI prefab.

    - I had an idea that each separated environment's top level game object should be a prefab (a prefab with Canvas + CanvasScaler), so it links with various setup in my game.

    -- However environment scene with prefab at root (not normal GO, "blue text (Environment)" not "greyed out text (Environment)") will make the thing entering prefab mode appears with + icon because it is now essentially an added object (to environment prefab), and dirty asterisk instantly appears to the prefab you are working on always. So I cannot use this workflow. Weirdly, you can even apply the prefab you are working on to the environment's prefab.

    --- Solution : Treat prefab in the environment as "unpacked completely"?

    - I have to design multiple of 16:9 image which has an another version of itself that can be fitted and masked in a 1:1 square rectangle. I made a variant of each 16:9 image and want to work in a square environment (So I can aim the important part of that 16:9 image to not be cropped out individually, depending on image's content)

    -- Prefab mode always attach things you want to work as a direct child of only top level canvas.
    -- The nature of Canvas component is that it is shaped after the Game view.
    -- I can set the game view to 1:1 to make the design canvas square shaped, but its coordinate boundary is still based on the game view.
    -- I can make a new aspect preset of the game view as not based on aspect but fixed number of pixel. Now I am able to get the exact canvas size and aspect to work with.
    -- Now my game view looks deformed and not like the actual game, just because I want the prefab mode canvas to looks right.
    -- It feels "hacky". This whole thing should be somewhere, adjustable freely in the prefab mode without relation to the game view? Because I do want to see the actual (non-squared) game in the game view as I work on the prefab.
    -- I am thinking of creating a nested invisible Panel in the environment with Aspect Ratio Fitter to fit the parent with ratio 1:1, so no matter what the game view currently is I get a square (in a rectangle) to work with. But then environment does not support placing what you want to work with anywhere else other that the top level canvas.

    --- Solution : A root level Canvas of the UI environment should have a special behaviour, maybe you could type in the size you want directly in the RectTransform or by some means through the Canvas component. Make them not greyed out.

    My opinion : "Environment" this keyword might be appropriate for 3D scene design but it is not the right choice for UI design.
     
    Last edited: Dec 19, 2018
    Mistwraithe, joshcamas and SugoiDev like this.
  2. Mistwraithe

    Mistwraithe

    Joined:
    May 28, 2017
    Posts:
    4
    What 5argon said. I'm finding it a nightmare to edit UI prefabs in Prefab Mode. Sounds like he is doing a bit better than me, I can't even get my prefabs to appear properly on my UI Environment canvas, they always appear centred on the bottom left corner so three quarters of the prefab is off the canvas with no background behind them.

    Prior to 2018.3 I did all my UI editing in the Game tab which shows UI elements properly but that doesn't work at all in Prefab mode.

    Did the Unity devs test the new prefab system with UI? Seems not really?
     
    kevinrodrigues and Rich_A like this.
  3. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    This is indeed intended behavior, but it seems it's not woking correctly. We've noted it down and will work on a fix.

    In the mean time you can drop this script FixUnpackEnvironmentUIParent.cs into your project to make it work:

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using UnityEditor;
    3. using UnityEditor.Experimental.SceneManagement;
    4.  
    5. [InitializeOnLoad]
    6. public static class FixUnpackEnvironmentUIParent
    7. {
    8.     static FixUnpackEnvironmentUIParent()
    9.     {
    10.         PrefabStage.prefabStageOpened += DummyMethod;
    11.     }
    12.  
    13.     static void DummyMethod(PrefabStage stage) { }
    14. }
    15. #endif
    A lot of the other issues you mention are related to the default Canvas and how it resizes with the Game View, and sound like they can be addressed by using a UI Envonment scene. We know the UI for setting and changing this scene is not ideal. See the FAQ.

    Rune
     
    5argon likes this.
  4. mathias_unity633

    mathias_unity633

    Joined:
    Jul 17, 2018
    Posts:
    35
    Hi @runevision , was there any updates on being able to change the UI Environment scene? Afaik the FAQ just mentions it's coming. If there's any hack or official way to change it, please let us know. It's really hard to develop UI when you have to switch back and forth between the scene and the prefab (otherwise love nested prefabs, so worth it overall ;))
     
  5. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    No, no updates. We're working on bug fixes and other Prefab features that were more widely requested, and we can't do everything at once.

    Also, the FAQ doesn't say it's coming. It says that "we’d love to look into it" which is true but only means literally that. That we completely understand it would be great to do something about, and we'd love to do that if it's possible. In practice it's unlikely we'll be able to get to all the features that we'd love to look into, because it's competing with lots of other priorities.

    The EditorSettings class seems to be undocumented but public. There you can use the properties prefabRegularEnvironment and prefabUIEnvironment.
     
    Last edited: Feb 14, 2019
  6. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I am curious which workflow I mentioned you are having problem with in commercial use, and what make that feature ready for commercial use before but not anymore in the new prefab update? Despite all the thing I wrote I can't see any deal breaker that needs to be reverted to "restore" a certain thing (if any feature disappeared at all).
     
  7. mathias_unity633

    mathias_unity633

    Joined:
    Jul 17, 2018
    Posts:
    35
    I forgot about this thread, but I just started setting my editor game resolution to whatever the canvas scaler was downsizing to, so I get the same sized prefab view.
     
  8. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    I guess I was overly negative! Frustration must have got the better of me... we all have those days.

    Funny thing is I've come around that the new Prefab system is actually pretty good for new projects. Very good even.

    Just a huge PITA for any existing, glued-together games that were expecting a clean transition to the LTS release without any major roadbumps (this is a major roadbump).

    (Yes, I think I deleted one myself, there is no conspiracy from Unity, they are decent folks who put up with us. They just need to work hard on getting prefabs right - they are the central component of workflow for people like game designers and level designers)
     
    Last edited: Mar 11, 2019
    jrumps likes this.