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

Splash Screen Flickers on android device

Discussion in 'Editor & General Support' started by J4CKL, Jan 30, 2013.

  1. J4CKL

    J4CKL

    Joined:
    Jan 30, 2013
    Posts:
    2
    I have made an app (Runner, from the tutorial), when I built the game and ran it on my Nexus 7 tablet, the default 'powered by unity' splash screen appears for a second or two, then starts to flicker (like a strobe) on and off. I decided to change the splash screen to a custom made one (in paint) and that consisted of the same problem? :confused::confused::confused::confused::confused:

    Please Help!
    Thanks in advance :)
     
  2. babis

    babis

    Joined:
    Apr 17, 2013
    Posts:
    1
    hello, I have the same problem... Have you fixed it?
     
  3. Bonobo

    Bonobo

    Joined:
    May 10, 2013
    Posts:
    6
    I have the exact same problem and I am also using a Nexus 7. The strange thing is, I have previously built and played the game just fine on my tablet. Since then I have added several features and updated my Android SDK tools, so I'm not sure exactly what I did to create the problem or whether the problem was even created by something that I did in my Unity project.

    I'm going to create a new test project to see if that is able to build correctly.

    If anyone has had similar issues, or knows how to fix this, then any help would be greatly appreciated.
     
  4. Bonobo

    Bonobo

    Joined:
    May 10, 2013
    Posts:
    6
    babis, what type of android tablet are you using?
     
  5. Bonobo

    Bonobo

    Joined:
    May 10, 2013
    Posts:
    6
    I have found and fixed the problem.

    I am using an Orthographic Camera and I was setting the orthographicSize to 0.

    In order to keep everything the same size when the Screen.orientation changes, I needed to change othographicSize when the orientation changes. To do so I created a scalar to change the orthographicSize when the screen's orientation is Landscape.

    My original code to calculate the Orientation Scalar was:
    fOrientationScalar = Screen.width / Screen.height;​

    The problem was that because Screen.width and Screen.height are readonly variables, fOrientationScalar was set to 0.

    Changing the code to this solved the problem:
    float fWidth = Screen.width;​
    float fHeight = Screen.height;​
    fOrientationScalar = fWidth / fHeight;​


    tl;dr
    1. If you are using an Orthographic Camera, make sure that you are not inadvertently setting the orthographicSize to 0.

    2. If you need to calculate a value using Unity’s readonly variables, store their values in your own temporary variables first and then use the temporary variables to do the calculation.

    Hope that helps you guys.
     
  6. bigpants

    bigpants

    Joined:
    Dec 9, 2009
    Posts:
    48
    The problem likely isn't the fact Screen.width and Screen.height are read only,
    the problem is the fact they're integer.
    And dividing 2 integers produces an integer so on a phone 1080 / 1920 = 0.56 gets truncated to 0.
    You fixed this unintentionally by converting width to a float!
    You could also have solved it with this:
    fOrientationScalar = ((float) Screen.width) / ((float) Screen.height));