#UI Elements randomly change size on Android

1 messages · Page 1 of 1 (latest)

eager oasis
#

For some reason some UI elements randomly chance their size, not their scale, their size, on Android, not in the editor. Why could this be the case and how can I debug this?

#

The problem is not present when using exactly the same resolution in the Unity Editor as on my phone

eager oasis
#

both text components have a content size fitter

eager oasis
#

I've been trying to fix this issue for four days now, can someone please help?

#

Oh I forgot an important detail, the second text has these components/settings

eager oasis
#

Can someone please help?????

civic canopy
#

When you say they randomly change size - do they continually change their size during gameplay, or are they set to random sizes each time you run the game? Is it always the same elements that are altering in size, or is it different elements each time? Also - can we get a look at your hierarchy? If any of your wrappers are managed poorly, they can have cascading effects on all their child objects, which could account for some of your problems. I'm going to assume you're using Scale With Screen Size as your UI Scale Mode on the Canvas Scaler.

eager oasis
eager oasis
eager oasis
eager oasis
civic canopy
#

instantiated via script?

eager oasis
#

yeah

civic canopy
#

can you show that code?

eager oasis
#
                userTemplate.SetActive(true);
                GameObject clone = Instantiate(userTemplate, usersParent);
                clones.Add(clone);
                UserReferenceScript UserReferenceScript = clone.GetComponent<UserReferenceScript>();
                UserReferenceScript.userNameText.text = item.DisplayName;
#

not sure which part you want

civic canopy
#

just wanted to see if there was any formatting in there that could be contributing to your issue

#

i don't have a ton of experience developing for mobile platforms, so i'm spitballing here, but maybe try to make use of directives and add formatting options while being compiled on a mobile setting? something like:

// your code here
#if UNITY_ANDROID
// android specific formatting
#endif
eager oasis