Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Bug Layout Group Component cause unwanted scene changes due to the floating point values

Discussion in 'Editor & General Support' started by modernator24, Jun 15, 2020.

  1. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    206
    After I added Layout Group Component, each time I opened the scene, it always makes unwanted scene changes. I figured out that the value was updated something like this:

    m_AnchoredPosition: {x: 0, y: -236.6} -> m_AnchoredPosition: {x: 0, y: -236.59961}

    This keeps making me not check the difference between pushing the changes to version control. Sometimes there are dozens of changes those floating-point values, just opened the scene used layout group component.

    Is there a way to prevent this?
     
    PraetorBlue likes this.
  2. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    206
    This floating-point value changes also cause failed to auto-merge in Git, each time I try to merge changes from different branches, I always have to fix it manually, even I didn't touch the scene at all.
     
  3. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    206
    Hello? Anybody?
     
  4. Yes, actually. Don't use LayoutGroups. :D LayoutGroups are the evil, regardless of this. And I'm not joking.
     
    modernator24 likes this.
  5. HiddenMonk

    HiddenMonk

    Joined:
    Dec 19, 2014
    Posts:
    987
    Is the layout group in a prefab? It was for me and going to it in the scene and applying the changes for it seemed to make it go away. (Actually I think it was a scrollrect causing this issue for me, but prob the same issue).
     
    modernator24 likes this.
  6. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    206
    That's really frustrating
    Is there any alternative thing to replace work similar to Layout Group components? Let's keep away from these evil things.
     
  7. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    206
    Wow, I never thought about that, and looks kinda great idea. Of course, that's not a solution, but maybe I can keep my change history clean. Thanks, I'll definitely try that until the Unity team fixes it.
     
  8. Unless you __really__ need them, you always better off calculating the layout yourself. LayoutGroups are one of the greatest performance eaters in the entire UI.
     
    modernator24 likes this.
  9. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    206
    I didn't know that there is a high-performance cost with using them. I used them a lot in my many projects and never felt a performance drop before, but have to learn how to calculate UI myself. Thank you.
     
  10. Obviously if you don't have any performance issues using them, then be it, just keep in mind that LayoutGroups are among the first contenders when you need to change something due to performance issues. :)
    Although learning how to calculate layout is always useful.
     
    modernator24 likes this.
  11. modernator24

    modernator24

    Joined:
    Apr 7, 2017
    Posts:
    206
    However, is Unity dev teams not gonna fix this issue? Or are they think it's not a bug or something? I'm still very frustrated with how this official built-in feature is evil. I think most of layout related components always make changes even that I didn't touch at all, not just Layout Group component, also something like ContentSizeFitter as well.

    I attached the captured screenshot when the moment that Unity makes "unsaved changes" even not touched anything. I tracked what this RectTransform located, and found that the object contains this RectTransform also contains ContentSizeFitter. I'm not sure ContentSizeFitter caused this change, but still, those auto-layout things keep make unwanted unsaved changes and sometimes cause annoying git merge fails.
     

    Attached Files:



  12. There is really nothing to "fix". It is the way the entire UI works. And this is the reason (among other things) why UI Toolkit was born.