When using a Vertical/Horizontal layout group that changes sizes of children as a parent of a Responsive Container hierarchy, I get really strange behavior and different results depending upon if I am running in editor or running standalone build. Also, sometimes the issue seems to be fixed, until I close Unity and restart it, then the issue comes back. I definitely see NaN when things are messed up.

We use a lot of prefab objects so that we can line up the information we are trying to display in different orientations on the screen depending upon project needs. e.g. Horizontally across the top of the screen, or vertically down the side of the screen.

Originally, there were situations where we couldn't duplicate the container behavior with just Responsive UI components. However, we now have more experience with Responsive UI and I am in the process of trying to remove the layout groups and switch to use Responsive components.

But it may be worth looking into and maybe adding a detection for the situation and issuing a warning or something.

    dtappe Thanks for reporting, once you have changed the layouts to Responsive components, can you post an update?
    Also if you can upload a demo scene with the current issue giving NaNs, I could have a look and try/catch the problem maybe.
    thanks!

      Anthony When I originally ran into the NaN problem, I tried to create a simple scene to duplicate the NaN's but was not successful. If I get some time I will try again.

      Yes, I will post an update once I have changed the layouts to only use Responsive components.

        FYI, for the layout groups that cause problems, we have the following selected:

        • Control Child Size: Width, Height
        • Child Force Expand: Width, Height

          I think the NaN issue is an incompatibility between how Layouts work and how Responsive UI works. I definitely do not know the details, but expect that it has to do with how prefabs width/height/pivot are used by layouts. IIRC, layouts use multiple frames to determine layouts and sizes to handle dynamic sized text objects, etc.

          It may be enough just to detect that a Responsive component is a child of a layout group and give a warning. I suppose you could also check to see:

          • If the layout group will be changing child sizes.
          • If there is a layout group on the same object as a Responsive Container
          • etc.

          @Anthony,
          I have also managed to create a NaN issue using ONLY Responsive components:

          In this project, I have forced Responsive Container OnChange to behave like OnUpdate so that I did not have to go through and change all of the Responsive components. I have also disabled most of my other changes.

            FYI, it looks like you can get NaN's also by using the "stretch" mode in the rect transform.

              btw please don't post links with the full plugin source code. Only post a .unitypackage containing the demo scene and your additional script, thanks!

                I opened your project "ResponsiveUiTest-3-OnChange-Tmp" and I don't really see the issue, the only NaN I guess does not seam related:

                transform.localPosition assign attempt for 'txtInputField Input Caret' is not valid. Input localPosition is { 0.000000, NaN, 0.000000 }.

                I clicked on "Toggle UI Location" and "toggle image" but I don't see what is the problem exactly.

                  Yes, that is one of the NaN errors. I believe it is caused by some adverse interaction between Responsive UI and Unity Layout and/or Stretch behavior. When I remove the "stretch" and "layout" stuff, and purely use Responsive UI, I don't get the NaN errors. However Responsive UI doesn't provide all of the functionality of the Unity layout system, so there are things that can not be done without mixing them. With "stretch", I know often the height/width is 0 until the systems figures things out, so I expect that is part of the issue.

                  Also, sorry about posting the code, I didn't even think of that as an issues. Do you have another way I should share information then?

                    dtappe Yes unfortunately they are not compatible. if you miss a feature that you think could be a great addition please let me know!

                    For sharing the demos, as I said above, just a unitypackage with a scene and your own scripts, otherwise send me an email 😉

                      Write a Reply...