#UI Elements randomly change size on Android
1 messages · Page 1 of 1 (latest)
The problem is not present when using exactly the same resolution in the Unity Editor as on my phone
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
Can someone please help?????
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.
They change size in the first few frames they are present in the scene, to different widths
Scaling isn't the issue, The problem is not present when using exactly the same resolution in the Unity Editor as on my phone
You can look at the Hierarchy in the left of the first image
Always the same elements, they are instantiated from one object
instantiated via script?
yeah
can you show that code?
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
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
You can also just use if (Application.platform == RuntimePlatform.Android)