Building Non-Game Apps In Unity – How-To


3

Building non-game apps are one of my favourite ways to make cross-platform apps. I’m lazy and only want to make things once and building it in unity lets me do this and publish it anywhere.

Quick Answer

Building non-game apps in unity are very possible. The important thing is to disable all the game engine functionality that will not be used in your app. Lowering the target FPS will help massively where possible. This keeps CPU usage and file size down whilst publishing to many different platforms.

What Can You Build?

Building apps in unity in my opinion is so much easier when you only have to learn one language and platform to publish almost anywhere. These are the best things I would use unity to make non-game apps.

Rapid Development

Being able to get a build of your app quickly a minimal viable product (MVP). Is so valuable for new ideas, being able to make a quick app to make a proof of concept and get an idea if this is something to put your time into can be so valuable.

This is compared to making all the apps in native languages. This can save you time and money.

Cross-platform

Multiplayer or community apps will be great for developing on unity. Getting people from all platforms to use your app can explode your app’s growth. If you have a great app but it only available on the iPhone, then you are only limiting yourself by the number of people interested in your app with iPhones.

Building you app for all platforms gives you great growth potential on all platforms and you may find if you do get you app on a different platform that it may just be a lot more popular on a platform you didn’t expect.

Why People Don’t Make Apps With Unity?

This is still a game engine. You will be limited compared to native. Stuff like text and low-level integration with the hardware will be as good when making apps with unity.

Large File Size

Unity tends to make large build sizes. When building the same app in native will be many times smaller, in this day and age all phone has a lot more storage so if you can make the app many times easier, I wouldn’t take this as a game-changer.

High CPU Usage

Unity is still a game engine, it refreshed the page at 30-60+ times a second. This is going to be very taxing on the CPU even if your app isn’t running anything intensive. But you don’t need to refresh the page at this rate you can set it to whatever you like.

How To Reduce CPU Usage?

These are two easy steps to reduce CPU usage in your unity app.

Lower the FPS.

As mentioned above the FPS of your app will usually be set to 30-60+ this is very taxing on your CPU. You can lower this on start-up or dynamically depending on your use-case.

Changing this is easy it just this one line of code. You can put it in your start function or use it dynamically thought your app to change the FPS for active and static situations in your app.

Application.targetFrameRate = 10;

This is a nice easy line to get you CPU Usage way down, change the target framerate to whatever you like and works best for you. Start with 10 if it’s too slow bump it up a bit but if your app is static you may be able to go much lower.

Optimising The Player Loop

The player loop is what makes unity run, it is what makes up all the background functions and systems. We can disable all the functions and system that you will not be used in your app.

When considering that there are more than 60+ system that runs in the player loop and all of these have overheads on the CPU.

One of the systems I always disable is physics. When I’m making apps that are just UI and buttons there is no need for physics so I turn it off and the improvements are drastic.

Physics.autoSimulation = false;

Physics2D.autoSimulation = false;

Cutting out unused systems like this is the best way to cut out overhead in your apps. There are many systems as I mentioned so have a look for yourself and see what you may be able to do without.

I will caution you can easily break your app testing this so make sure you have your version control in place.

Here is a link to all the functions. Here.

Final thoughts

For testing and proof of concept, I think Unity has massive potential. If you already have an app and want to quickly test it cross-platform these are great uses.

Also trying to lower CPU usage in current apps and non-games apps these are great solutions.

If you think this is a good idea or have any other ideas, please leave a comment below and I’ll go in more depth if you are interested.

Research

Here are some useful links that may help you if you are looking into this a bit more

https://www.communicationcrafts.com/how-to-create-non-game-apps-in-unity/

https://medium.com/@thebeardphantom/unity-2018-and-playerloop-5c46a12a677

https://secretlab.institute/2019/06/14/power-saving-in-unity-for-non-game-apps/

https://gist.github.com/LotteMakesStuff/8534e01043826754344a570a4cf21002

https://forum.unity.com/threads/player-loop.515340/

https://assetstore.unity.com/packages/tools/gui/nativeedit-plugin-for-unity-ui-36358

https://assetstore.unity.com/packages/tools/integration/cross-platform-native-plugins-ultra-pack-31086