Unity3d has the best presentation layer for cross platform development out there. Compared to having to write everything multiple times for each platforms, or the difficulties of Xamarin, or even phone gap… Unity3d just blows the competition away.
When non game customers come to me with an Idea, 90% of the time Unity3d would do the trick… If it wasn’t for the battery drain.
Here is a picture comparing battery drain between a Xamarin Forms application and a Unity3d application.
Trepn profile is the tool. % use is normalized. Tests were for a period of 30 seconds each.
As you can see the Xamarin forms application uses very little battery compared to my empty Unity3d project.
To any Unity3d staff out there, is there a way we can make Unity3d more energy efficient ? If we could slow the update rate, or disable advanced shaders, or whatever ? Maybe a new menu where we can enable / disable features with an energy / space estimation.
I understand that Unity3d is at its core a game engine, but, vertical enterprises business have lots of money and I am certain that an update with support for an energy efficient mode would really expand Unity’s utility value.
Lastly, if this is possible but you need someone who has an understanding of LOB’s to bounce ideas off of or prototype, mail me.
Ultimately this is the issue with having a core tied so closely to the game loop. You could drop the target frame rate down, at the risk of making your ap unresponsive.
Most of the current unity users would be opposed to moving away from the core game loop.
There are things you can do to reduce the hit, and certainly we would all welcome continued improvement on unity’s side. But it is too niche and off-product to expect much movement from unity in that direction.
Tools for building apps are plentiful and feature rich, unity would have to change a lot to even come close, even then it would be tough to convince devs to change. If there was a clear gap or the market was under served, it might make sense but that’s just not the case. Though it is quite useful for non game apps that are 3d centric.
Niche in terms of devs that would use unity for non game/3d app development. Of course better battery usage would be fantastic, and I assume that unity is not ignoring it. But there is a certain amount overhead in a 3d engine and especially a game engine not needed for most non game apps. Decoupling that would be non-trivial, and not benefit their core use/audience.
Sure, but most such apps are already very well serviced by frameworks targeting that use case. The “niche” is stuff that is a hybrid of the two, and even that is likely to be well serviced in the not-too-distant future thanks to WebGL.
Not only non-game apps would benefit from this, games such as choose-your-path books (I think a few of them are made in Unity), turn-based tabletop inspired games and card games etc might/should also benefit (quite largely some of them) if you could slow down the core game loop/or something else to keep power usage down while keeping the game responsive when used.
Hmm, would something like this help:
public class PowerSavingTest : MonoBehaviour {
private bool _savingPower = false;
private float _lastNonSaveTime = 0f;
public void SavePowerMode(bool save) {
if (savingPower==save) return;
if (save)
Application.targetFrameRate = 5;
else
{
Application.targetFrameRate = -1;
}
savingPower = save;
}
void FixedUpdate() {
if (some kind of input)
{
_lastNonSaveTime = Time.time;
SavePowerMode(false);
} else
{
if (Time.time + 0.1f > _lastNonSaveTime)
SavePowerMode(true);
}
}
}
Native development in objective-C and java. This method has 0% code reuse. Simply put you need to write a new app for each platform. In the future no one should be doing this.
Webview technologies like cordova and phone gap. Developers make their applications in html, css, and js. These technologies are growing because they allow for 100% code reuse between iOS and Android. Their pitfall is that they use js and not everyone loves this. Moreover the web view has a performance hit.
Xamarin Forms. Developers use c# and xaml to make their applications. There is 95% code reuse across both platforms. The biggest pitfall is that their ui technology sucks. Specifically because it renders ‘native’ controls each platform functions and looks different.
Unity3d. With its world class UI, near 100% code reuse, and world class UI this is the best option for all mobile development. If this battery issue can be resolved ,any developer worth their salt should seriously look into unity for all mobile applications. Seriously, the second biggest hurdle is a perception problem. Marketing.
I currently support 2 non game applications. 1) a video conferencing app. 2) a customer and order management solution. I would love to move these into Unity.
At 1 FPS Im seeing CPU usage at about 8%. That is almost a 50% reduction.
I should add that Facebook has CPU use is about 5%. Keep in mind that Facebook has allot more going on that my simple button and slider… but, I think we might be in the ballpark.
I will run some more tests and write a blog post this week.
Even if they could improve it a bit you will still face Apple and iOS users that dislike apps that do not behave like normal apps. You might get away with simple looking apps but if there are a lot of views and UI behavior created in a custom way you probably will get rejected.
Xamarin does it like its supposed to be, native looking controls which of course behave and look different depending of the platform and version but in a way the platform users are used of. You also did not list all all options as there are also other solutions for multiplatform apps that do native controls.
If you don’t use native looking UI you are promoting the hated wild west apps where every developer has it’s own opinion of UI logic and behavior for controls. Users do not get consistent experience when every app has it’s own. This is the reason Apple and Microsoft have rules and guidelines for these while Android does not really enforce anything.
Can you expand on this ? Ive always seen this as a control issue solved by writing a toolbar, drawer, or other missing ui element. Ive seen this cliche quite a bit, but no one has ever backed it up with any substance.
Absolutely not. Apps with poor aesthetics should die. Has anyone ever complained about UI elements from unity ? As someone who uses both iOS and Android I have found the differences to be minimal. What they share is simplistic and intuitive design. That is what is important. The User does not care how we develop our UI, so long as it is quality.
I did not mean missing control types or such but non standard UI behavior. iOS apps should have controls, navigation, gestures, etc like you would expect them to be. I’m referring to the iOS app review guidelines and more specifically to sections about user interface and behavior. The rejections are based on how well the reviewer follows them but generally you can get the idea if you google around with say, section 10 rules and see how people have been rejected.
To get better idea, when you make an app with Unity and unless you don’t mimic these your app will not have the support for platform action menus such as copy/paste/dictate around different places, features that people with disabilities need (accessibility features), slide back and forth in views, lists with gestures, your buttons, navigation bars, toggles wont look like they do in normal apps and so on…
If unity chose to do this the farthest I could ever see them going is exposing a simple option to slow down the game loop to save battery a little bit. Anything beyond that is way outside of their focus. Frameworks that let their scope get too big become bloated and slower. When you become a jack of all trades you become a specialist in none.
Unity has enough problems and competition with UE4 in their core business to let themselves focus on anything else. If they did so it would be at their own peril.
If non-game applications are driven only through the gui, would it be possible to disable the game loop and just have events? Maybe enabling the game loop for simulation apps that have ongoing things that need a frame delta to show smoothly.
Drop to 30fps capped and do less logic in the same frame. Doing less logic == less battery, mobile cpus switch off as much as possible, same for the GPU.
It’s not actually any different to having a ‘power saving mode’. Just do less is the magic bullet.
I did that for an experiment in placing trees via raycast for a moving endless forest. I had a variable outside the loop keep track of the progress in placing trees and did it over several frames.
There are slightly more than a 4 options for app development. Tons. And the ones you listed not fully accurate.
native is always going to be more performant, devs will always use it. Especially for non games. Even for games, native is only slightly behind unity, and many of the biggest games are native. There tons of frameworks that support single code base. You aren’t limited to objC/Java.
performance hit compared to what? Maybe slightly slower than uikit but Unity UI isn’t even in the same ball park as web view. It’s just not built for it. Try using unity to display this web page for example. Additionally, this isn’t a new tech, it’s been built in since day one. Many of the first apps were web view driven, it is literally a single line of code to invoke WebKit.
unity UI is good, for a game engine, it has a ways to go. No one would call it world class though. Maybe one day, but not just yet. But again, only for a game engine. Outside of unity (or any game engine) pretty much everything has more robust / rich / powerful UI tools. Html is more powerful.
Unity is a game engine. If you only know unity, sure you can build apps in it, but there are many faster, more efficient, better performant and easier ways to build them, and there always will be, because it is its own industry. No amount of fixing will allow unity to perform at the same level without a fundamental shift in design. Which is unrealistic because a) game engine b) no need, there are dozens of better options.
Yes. To disable the game loop, go to File > Quit. Then open a text editor, or other editor/tool that is not built specifically for making games and go nuts!