• Unity
  • Any tips on how to minimize battery power usage?

I'm working on a R&D project to minimize power usage of a game built with Unity.
The game uses spine animations too.
Is there any tips on how to minimize battery power usage? (this question is identical to how to minimize system resources usage)
with, or without loss of quality.

Related Discussions
...

This is a rather big topic. I would suggest the following:

  • Disable GameObjects entirely where possible, e.g. when off-screen or similar. This keeps them from calling Update/LateUpdate. In the current version of the Unity runtime, Spine animations will update the mesh when offscreen [1], so you could add your custom culling-bounding-rectangle class that enables/disables GameObjects accordingly.
  • If you are using non-Spine Mecanim Animators too: set the Animator Culling Mode property to "Cull Completely" where possible (see documentation here: https://docs.unity3d.com/ScriptReference/AnimatorCullingMode.html):
  • Lower the target framerate if suitable (see https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html).
  • Parallelize whatever computations you perform - utilizing multiple threads/cores will be more energy-efficient than having a single core at 100% and all others idle.

I will add more items to the list as soon as they come to my mind. Let me know if this helped you and your project!

[1] Update performance and culling will be improved in future updates, we're currently evaluating multiple points of improvement for their impact on performance.

Harald a écrit

This is a rather big topic. I would suggest the following:

  • Disable GameObjects entirely where possible, e.g. when off-screen or similar. This keeps them from calling Update/LateUpdate. In the current version of the Unity runtime, Spine animations will update the mesh when offscreen [1], so you could add your custom culling-bounding-rectangle class that enables/disables GameObjects accordingly.
  • If you are using non-Spine Mecanim Animators too: set the Animator Culling Mode property to "Cull Completely" where possible (see documentation here: https://docs.unity3d.com/ScriptReference/AnimatorCullingMode.html):
  • Lower the target framerate if suitable (see https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html).
  • Parallelize whatever computations you perform - utilizing multiple threads/cores will be more energy-efficient than having a single core at 100% and all others idle.

I will add more items to the list as soon as they come to my mind. Let me know if this helped you and your project!

[1] Update performance and culling will be improved in future updates, we're currently evaluating multiple points of improvement for their impact on performance.

Thanks. This definitely helps.
I can't completely disable all GameObjects when they are out of sight, because some of them have movement animations too. But I'm working on disabling spine animations for them.
Any idea how can we parallelize computations? we are currently targeting Android and iOS.

Parallelizing computations (in general, not Spine-specific) could be done via using the Unity job system or entity component system (ECS) for example, which provides some nice abstractions and save you from managing threads and synchronisation manually.
Docs: https://docs.unity3d.com/Manual/JobSystem.html
Introduction Video: Unity at GDC - Job System & Entity Component System - YouTube
If this is not suitable, you could as a fallback manage your own thread jobs via e.g. C# ThreadPool.QueueUserWorkItem:
https://docs.microsoft.com/en-us/dotnet/api/system.threading.threadpool?view=netframework-4.7.2
However, in the latter case you have to be more careful with what you do.

About disabling GameObjects: In general it should be a nice optimisation to disable expensive components when not needed as well.
Also be sure to tweak AI-related code and Physics.Raycasts - quite often you don't need to execute such calls every frame, every N frames should be enough.