Nicholas Yang (nyanginator)

7 answers · asked · Lesson: Ending Tweaks · Course: Create a Rocketship Video Game in Unity

What steps to make mobile version?

I attempted to convert this into an Android app (ignoring ship controls for now) but ended up with some rendering issues:

Well, I guess my phone is pretty old (Samsung Note 2). But I'm wondering if I might've missed some steps. This is what I did:

  1. Switch to Android platform in Build Settings.
  2. Switch Color Space to Gamma in Player Settings.
  3. Set Company/Product Name and Package Name in Player Settings.
  4. Build and Run.
  • crew

    I would probably turn off the post processing as that may affect performance and I'm not sure how well post processing works on mobile to begin with. I would also try to bake the lighting using "subtractive" for the lighting mode. That's meant for mobile and web gl games as it's the most performant. 

    Everything else should be good to go. I assume you were able to build to your device in which case you should have the Android tools already installed and you were able to build to your Android "Api Level". The minimum you can build to is Android 4.1 Jelly Bean from what I see in Unity 2019. 

    • Disabling Post Processing Layer on Main Camera did the trick! It renders OK now and seems to animate smoothly. Here's another screenshot from my phone:

      For lighting, I tried:

      1. Unchecked Realtime Global Illumination. Enabled Baked Global Illumination and Lighting Mode: Subtractive.
      2. On the Directional Light, left the Mode on Realtime.
      3. In Player Settings > Quality > Shadows, I set:
        1. Shadowmask Mode: Shadowmask,
        2. Shadows: Hard Shadows Only
        3. Shadow Resolution: Medium Resolution
        4. Shadow Distance: 50
        5. Shadow Cascades: No Cascades

      I also applied a Max Size of 512 to the HDR texture used for the Skybox.

      Do these shadow settings make sense for optimizing?

      To be honest, I don't feel there's much difference with the lighting/shadow tweaks, other than the look of the shadows. But maybe I'm still struggling with grasping the concept of the many settings—what to use and when.

      On another note, I am getting some shadows with holes and rough edges. Not sure how to fix it:

      I was indeed able to build to my phone, I've actually had random luck with getting it to successfully upload and run on the phone whenever I do Build and Run. Sometimes it works and sometimes it doesn't. I've been trying things that people said in the forums, like changing USB ports, deleting the app before building, using "adb kill-server" and "adb start-server", restarting Unity, restarting the computer, restarting the phone, unplugging and replugging, etc. But I can't seem to figure out any pattern to it. It seems to only work when it wants :P.

    • crew

      If you bake lighting, the lights need to be set to baked, or mixed. So it only bakes out lighting if the lights in your scene support it. If all your lights are realtime it won't bake anything. I only mention baked lighting as it can be better for performance, but I think for this project we had like one light and the rest were emissive objects. So you could probably just run with realtime lighting  altogether. 

      When building, do you have your device selected within the build settings window? It should appear in here where it says "Run Device" 

      I don't have an Android device connected, but when you do you'll see a dropdown appear there allowing you to specify where you want to build it. Typically it will automatically find the device connected and build to that. 

      Whenever I build to a device I usually close down the app then use build and run again. If you leave the app open sometimes it doesn't properly update it. 

      If you're just testing you could also opt to try the Unity Remote: , it's not fool proof but it's a great way to quickly test things out on your device instead of having to build every time. 

    • Yeah unity remote is the bomb. When I want to see some functionality on my iPad I use that instead of dealing with distributing then posting through XCode.

    • Thanks for the replies. I initially tried Baked for the Directional Light, but then the rocket wasn't lit anymore. So I went with Mixed. But now the moon looks a bit dark and discolored, and shadows are really faded. Realtime still looks better in the end.

      Here is what my Build Settings look like:

      I think I do have better luck when quitting the app first, but still only occasionally successful in deploying to my phone. Oh, I'm on Linux, so I'm not sure if it has anything to do with that ... 

      One way I've been getting around the issue is just copying the APK file to my phone and installing it manually from there. But copying through the USB cable also seems to fail half the time. I also tried Bluetooth transfer, but that is extremely slow. The surefire approach has been to upload it somewhere online and then download it to my phone to manually install, but of course this is an extremely longwinded process.

      I remember you mentioning Unity Remote before, but I guess maybe the reviews scared me away and I figured it might not be worth the time. Maybe I'll get around to trying it eventually.

    • Yeah, after you use it the Unity Remote successfully you are going to ask yourself how you were able to live without it. It is as close to plug and play sandbox testing as I have been able to get with a physical device and a computer

    • I just tried it out and ... well, no dice unfortunately. I set:

      • Project Settings > Editor > Unity Remove > Device: Any Android Device
      • Connected USB cable and set File Transfer mode to MTP/PTP and enabled USB Debugging.
      • Started Unity Remote 5 app.
      • Started Unity.
      • Pressed Play.
      • Game starts on computer but phone doesn't do anything. :(
      • Tried restarting phone, restarting Unity, restarting Unity Remote 5 app, restarting computer, plugging/unplugging USB cable, etc.

      Seeing as how Unity seems to hang more often on my computer when quitting with my phone connected, I'd wager there's just something in my hardware/software that just isn't getting along with the whole setup.