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:
    262
    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:
    217
    Does your 'Dropdown' GameObject in your second example have a Canvas component on itself?
     
    Lucifer95 and QuantumCalzone like this.
  3. QuantumCalzone

    QuantumCalzone

    Joined:
    Jan 9, 2010
    Posts:
    262
    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:
    68
    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:
    217
    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.
     
    ismaelnascimentoash likes this.
  6. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    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:
    68
    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:
    760
    @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:
    9
    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

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    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.
     
  12. unity_scotty

    unity_scotty

    Joined:
    Oct 13, 2019
    Posts:
    3
    Not sure if this is something related, I am new to Unity. My prefab contains a Canvas in WorldSpace render mode. After I initialized the prefab, all UI components (button, dropdown etc) are not clickable. Not sure how to fix this...

    Ignore my message if this is not the same issue.
     
  13. cdr9042

    cdr9042

    Joined:
    Apr 22, 2018
    Posts:
    173
    I got this bug in 2019.4.8f1, I have to add a Canvas Renderer component to my prefab for it to get UI Environment in Prefab edit mode correctly
     
    TokyoWarfareProject likes this.
  14. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    814
    same here, some prefabs work out of the box, some other I've to add manually
    Unity 2020.1.4f1
     
  15. FedericoBozzo

    FedericoBozzo

    Joined:
    Dec 7, 2020
    Posts:
    1
    Bump!
    Same issue in Unity 2019.4.21: only prefabs that get the canvas in prefab editing mode are the ones with a canvas renderer on them, all the others don't.
    Also, the ones that don't fail in getting the correct Prefab Editing Environment as well.
     
  16. OnatKorucu

    OnatKorucu

    Joined:
    Apr 18, 2018
    Posts:
    8
    I faced this issue when creating a prefab variant from a prefab with canvas on it. Solved it by disabling the canvas in the main prefab, creating the variant, and re-enabling the canvas in the main prefab. Unity version is 2020.3.3.
     
    robinryf likes this.
  17. jonathanglitchers

    jonathanglitchers

    Joined:
    Jan 5, 2023
    Posts:
    8
    This was basically it for me, thanks.

    The hiearchy's like:

    ViewController
    - Canvas <-- canvas here
    -- Content

    So it's 1 below the parent.

    The solution has been just to throw in a component *anywhere* with a CanvasRenderer

    e.g.

    ViewController
    - Canvas <-- canvas here
    -- Content
    ---- Image <--- has the CanvasRenderer

    It's not ideal, but hey.
     
    Last edited: Jul 12, 2023
    chikchik likes this.
  18. pacificeve

    pacificeve

    Joined:
    Jan 6, 2018
    Posts:
    9
    I experienced this with 2022.3.14f1 I had to remove all the canvas components and the canvas itself, save the prefab, then add canvas stuff back in and it fixed it for me
     
  19. pacificeve

    pacificeve

    Joined:
    Jan 6, 2018
    Posts:
    9
    and when I compile or run it in editor it sets it back and breaks it.. hmmmm