Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Visual Bugs After Version Change in Android Builds

Discussion in '2D' started by unity_bu1zWp-Jk79O2g, Jul 11, 2023.

  1. unity_bu1zWp-Jk79O2g

    unity_bu1zWp-Jk79O2g

    Joined:
    Feb 3, 2023
    Posts:
    5
    Hi,
    We recently wanted to upgrade our Unity version from 2021.3.11f. We first tried to upgrade it to 2021.3.27f1, game was running fine in Editor while simulating Android and on Ios build. However, on Android Builds visuals were very glitchy, it looked like Atlas could not display the sprites properly. On locations where it should have displayed a singular sprite, there were dozens of sprites. We couldn't find the reason of why that is happening after trying lots of different stuff. Then, we tried to upgrade to 2022.3.4f1 thinking this could be due to the specific version we upgraded or maybe it was a bug that was solved later in a new version. The same bug also happened in this version. Then we uncrossed include on build to all the sprite atlas to understand if it was in fact due to sprite atlas not processing properly. Then the sprites were not even displaying on the scenes. There is one scene where one sprite atlas is shown properly. I will be adding two attachments. The first one showing sprites not showing properly with sprite atlas included on build. The second one is when we don't include them in our build. I also added the config we use for sprite atlas which we don't override in Ios or Android. Any help or guidance is appreciated. Thanks.

    Atlas included on build:
    atlas.jpg

    Sprite Atlas unchecked:
    sprites.jpg

    Config:
    config.jpg
     
  2. DanielTanBK

    DanielTanBK

    Unity Technologies

    Joined:
    Aug 20, 2019
    Posts:
    80
    Hello, we are unable to reproduce this issue just from the screenshots you have provided. You could create a bug report and provide us with more information for investigation.

    This behaviour is expected as the reference atlas texture is not automatically loaded when the box is uncrossed.
    More infomation in our documentation: https://docs.unity3d.com/Manual/SpriteAtlasDistribution.html#Dontinclbuild
     
  3. unity_bu1zWp-Jk79O2g

    unity_bu1zWp-Jk79O2g

    Joined:
    Feb 3, 2023
    Posts:
    5
    After investigating the issue a little bit more, we found out this is due to running the build via fastlane unity_plugin which takes the build from command line. When we start the build through editor. The visuals look fine on Android. There was some customization in the build script the unity_plugin was running, we removed all of that to eliminate any differences of build through editor and command line. But the issue still persists.
    Is there anything in command line vs editor builds that could account for this sort of difference?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Another possibility is you have ambiguous sprite sorting orders specified, eg, two sprites on the same sorting order / sorting layer combo.

    Three (3) primary ways that Unity draws / stacks / sorts / layers / overlays stuff:

    https://forum.unity.com/threads/orthographic-camera-rendering-order.1114078/#post-7167037

    In short, as far as the Standard Rendering Pipeline,

    1. The default 3D Renderers draw stuff according to Z depth - distance from camera.

    2. SpriteRenderers draw according to their Sorting Layer and Sorting Depth properties

    3. UI Canvas Renderers draw in linear transform sequence, like a stack of papers

    If you find that you need to mix and match items using these different ways of rendering, and have them appear in ways they are not initially designed for, you need to:

    - identify what you are using
    - search online for the combination of things you are doing and how to to achieve what you want.

    There may be more than one solution to try.

    For instance, you may even use multiple co-located cameras to more-explicitly control apparent draw ordering.

    Additional reading in the official docs:

    https://docs.unity3d.com/Manual/2DSorting.html

    And SortingGroups can also be extremely helpful in certain circumstances:

    https://docs.unity3d.com/Manual/class-SortingGroup.html

    Other rendering pipelines may have other ways of layering (HDRP and URP). Go see the latest docs for details.
     
  5. unity_bu1zWp-Jk79O2g

    unity_bu1zWp-Jk79O2g

    Joined:
    Feb 3, 2023
    Posts:
    5
    Thanks for taking the time for a detailed explanation. We decided to upgrade to 2021.3.22f which worked unproblematically. We'll now consider and look into these suggestions to upgrade to a new major version. Thanks a lot again.
     
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,563
    Only if you need to!

    ISSUES RELATED TO UPGRADING PROJECTS (eg, changing to a higher Unity version)

    Upgrading to a later version of Unity is a one-way process. Any project that has been updated should NEVER be reverted to an earlier version of Unity because this is expressly not supported by Unity. Doing so exposes your project to internal inconsistencies and breakage that may actually be impossible to repair.

    If you want to upgrade to a newer version of Unity, do not even consider it until you have placed your project fully under proper source control. This goes double or triple for non-LTS (Tech Stream) versions of Unity3D, which can be extremely unstable compared with LTS.

    Once you have source-controlled your project then you may attempt a Unity upgrade. Immediately after any attempted upgrade you should try to view as much of your project as possible, with a mind to looking for broken animations or materials or any other scripting errors or runtime issues.

    After an upgrade you should ALWAYS build to all targets you contemplate supporting: iOS and Android can be particularly finicky, and of course any third party libraries you use must also "play nice" with the new version of Unity. Since you didn't write the third party library, it is up to you to vet it against the new version to make sure it still works.

    If there are issues in your testing after upgrading Unity, ABANDON the upgrade, revert your project in source control and be back where you were pre-upgrade with the earlier version of Unity.

    Obviously the less you test after the upgrade the more chance you will have of an undiscovered critical issue.

    This risk of upgrading is entirely on you and must be considered whenever you contemplate a Unity version upgrade.

    Do not upgrade "just for fun" or you may become very unhappy.

    PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL

    I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

    Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

    You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

    Here is how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up an appropriate .gitignore file for Unity3D:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally the ONLY folders you should ever source control are:

    Assets/
    ProjectSettings/
    Packages/

    NEVER source control Library/ or Temp/ or Logs/
    NEVER source control anything from Visual Studio (.vs, .csproj, none of that noise)

    Setting git up with Unity (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity

    It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

    If you plan on joining the software industry, you will be required and expected to know how to use source control.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards
     
  7. unity_bu1zWp-Jk79O2g

    unity_bu1zWp-Jk79O2g

    Joined:
    Feb 3, 2023
    Posts:
    5
    Thanks a lot for all the information. We are already using git or we would be in shambles :) We'll probably experiment with the new major version and make lots of test before completely switching. If someone will see this thread in future and have the same problem. I want to note that. What I wrote before was wrong, in android builds through the editor was also faulty in version 2021.3.26. However, it is interesting that one of the builds from the editor in 26 and 28 versions worked fine until I sent it to a jenkins build server which resulted faulty. Then I ran the same script from jenkins which is a fastlane unity_plugin script that is building in batch mode that resulted faulty as well and after that the builds on editor also became faulty. Not sure the reason of that.