Search Unity

Canvas (Environment) not always above RectTransform prefab in Prefab Edit mode

Discussion in 'Prefabs' started by QuantumCalzone, Sep 16, 2018.

  1. QuantumCalzone

    QuantumCalzone

    Joined:
    Jan 9, 2010
    Posts:
    246
    I'm not sure the exact reproduction steps but some of my UI prefabs do not have a Canvas (Environment) as a parent when I edit them.

    An example of an object with Canvas (Environment) and its RectTransform component.
    An example of an object without Canvas (Environment) and its RectTransform component.

    Is this intended behavior and I'm missing something? Is there a way to make it consistently be placed under a Canvas (Environment)?
     
  2. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    92
    Does your 'Dropdown' GameObject in your second example have a Canvas component on itself?
     
    QuantumCalzone likes this.
  3. QuantumCalzone

    QuantumCalzone

    Joined:
    Jan 9, 2010
    Posts:
    246
    That's it! There was a child with a Canvas. I removed it and now I can ensure my prefab's root RectTranform data is editable. Thank you!
     
  4. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    44
    Hello.
    My UI Prefab has one canvas, because my per panel has one canvas.
    so. can you have a option that put my prefab with canvas in canvas Environment.

    Thanks.
     
  5. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    92
    Have you tried to create an empty scene with your Prefab with only that Canvas in it?
    And then assign that scene to the UI Environment in the Editor Settings.
     
    ismaelnascimento01 likes this.
  6. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    92
    We have found a bug where if you have a Canvas in your prefab we wont reparent the opened prefab root correctly to either the environment scene Canvas or a automatically created Canvas. Fix coming...
     
    optimise likes this.
  7. litefeel

    litefeel

    Joined:
    Dec 6, 2016
    Posts:
    44
    Thanks for your response.
    Yes. I want a nest canvas.
    one in ui environment, and another in prefab.
     
  8. TheValar

    TheValar

    Joined:
    Nov 12, 2012
    Posts:
    752
    @Mads-Nyholm
    what's the status on this? I have a project where many prefabs have their own canvas and this is causing me some issues.
     
    adecker_MG and Cathero like this.
  9. adecker_MG

    adecker_MG

    Joined:
    Oct 24, 2017
    Posts:
    2
    @Mads-Nyholm Any word? This causing issues with my prefabs and messing with their rendering at runtime after editing in the prefab view. Even an issue tracker number would help
     
    TheValar likes this.
  10. macagu

    macagu

    Joined:
    Sep 30, 2012
    Posts:
    4
    I had a similar issue with canvases on nested prefabs, using Screen Space render mode.
    Whenever i edited some of these (entered prefab mode in scene view), the Canvas (Environment) was displaying too small calculated sizes (grayed out), making no sense as reference to edit the contents.

    Workarounded it by defining a custom ui environment scene (Edit > Project Settings > Editor > Prefab Editing Environments > UI Environment) with a Canvas using World Space as render mode, with a fixed Width and Height.
    Now when i edit the nested canvas, its using that fixed canvas, which is a lot better as a referece.

    I have also experienced some issues with the values auto calculated on the Canvas (Environment) when entering and exiting play mode. Workarounded by enter and exit play mode again.

    I'm using Unity version 2019.1.6f1
     
    Last edited: Jun 19, 2019
  11. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,598
    Issues where nested Canvas Prefabs didn't get a parent "Canvas (Environment)" in Prefab Mode should all be fixed in the latest versions of 2018.3, 2019.1, 2019.2, 2019.3. (One edge case fix is still in queue for 2019.1 but it's only for nested Canvas Prefabs where there's no CanvasRenderer anywhere in the Prefab (e.g. no visual elements), which is not the common case.)

    If anyone are still having issues with this (e.g. parent "Canvas (Environent)" missing in Prefab Mode where you'd expect to have it) then please file bug reports for it, as none the ones we have reproduce anymore.

    For other issues that are not related to a missing parent "Canvas (Environent)", please don't use this thread but start new threads instead, or just directly file bug reports if you believe it's a bug.