Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Rect Position of Scroll View's Content changing value when Canvas component is disabled

Discussion in 'UGUI & TextMesh Pro' started by el_Guero, Dec 7, 2023.

  1. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    I probably do not understand some things about Scroll Views and Unity UI System, but this looks like a bug to me. At least the behavior is completely nonsense.

    When I disable the canvas component, the 'content' game object of my scroll view starts to go completely nuts and increases its Y-Position value continuously until infinity and beyond. This happens both, at runtime and just in editor mode.

    When I enable the canvas component everything is fine.

    When I enter play mode with the canvas component enabled, everything is fine too. I can then disable and enable the canvas without any issues and everything continues to stay fine.

    So a solution right now is to enable the canvas and disable it again in the same frame at the very start at runtime. This then allows to set the position of the content when needed and everything is fine too.

    But this shouldn't happen in the first place, right? I mean what has the Scroll View to do with the canvas component? Or why would the canvas component affect the content's position when disabled in the first frame at runtime?

    I use Unity 2022 LTS.

    Edit: seems this has been an issue for some while now: https://forum.unity.com/threads/ver...e-if-canvas-was-disabled-before-play.1333647/
     
    Last edited: Dec 7, 2023