能源效率unity3d - 停止的应用程序等待用户交互 [英] Energy efficiency in unity3d - halting app waiting for user interaction

查看:342
本文介绍了能源效率unity3d - 停止的应用程序等待用户交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一种方法,使我unity3d应用的睡眠,同时等待用户交互(触摸,鼠标或键盘事件)或定时器(分钟级)。

I am looking for a way to make my unity3d app sleep while waiting for user interaction (touch, mouse or keyboard event) or timer (minute-scale).

该应用程序是比游戏更接近一个电子书阅读器。用户交互是最好的形容为阅读文本的一个非动画墙99%的时间。有时是有背景音(最大的时间的5%),它是由相互作用启用。目标平台是安卓,iOS和Web播放器。

The app is closer to an e-book reader than a game. The user interaction is best described as reading a non-animated wall of text 99% of the time. Sometimes there is a background sound (max 5% of time), it is enabled by interaction. Target platforms are android, ios, and webplayer.

渲染,甚至与普通FPS单一的纹理会耗尽相当一些能源。(手工测量,从字面上 - 该设备是暖)

Rendering even a single texture with normal FPS can drain quite some energy (measured by hand, literally - the device is warm).

我的主要问题是,我不希望渲染相机所有的时间,但我确实需要对用户输入的反应用尽可能少的滞后越好 - 所以降低了FPS不能很好地在这里工作(输入等待下一帧)。

My main problem is I don't want to render the camera all the time, but i do need to react to user input with as little lag as possible - so lowering the FPS does not work well here (input waits for the next frame).

那么,如何才能制止以节能的方式等待用户输入的应用程序?只是一个平台上工作(如集成了原生API)提示,也欢迎。

So, how can i halt the application waiting for user input in an energy-efficient way? Hints working for just one platform (like integrating a native API) are also welcome.

推荐答案

团结内部架构是一个游戏。作为有一个无限循环包括更新()和渲染()和它的运行速度,因为它可以。也许,您可以更改自定义插件的这种行为,所以选择№1。

Unity internal architecture is that of a game. There as an infinite loop consisted of Update() and Render() and it's runs as fast as it can. Probably, you can change this behaviour with custom plugin, so there is option №1.

选项№1。团结是(仍然)单线程的。但是,在多线程管理的环境。你可以叫睡在你的脚本和应用程序将睡觉的时间没有更新()既不渲染()调用。问题是,统一在同一个线程中运行它的输入。但在理论上,你可以创建自定义插件,并实现输入在另一个线程运行。因此,你将能够把统一使用类似WaitFor的(customInput)有条件的睡眠。当然,你将需要单独执行插件为每个平台。

Option №1. Unity is (still) single-threaded. But it is in multi-threaded managed environment. You may call Sleep in your script and application will sleep for a time with no Update() neither Render() invoked. The problem is that Unity run its input in the same thread. But in theory you can create custom plugin and implement input running in another thread. Therefore you will be able to put Unity to conditional sleep using something like WaitFor(customInput). Of course you will need separate implementation of plugin for each platform.

这不是一个简单的答案,是吧?然而,还有另一种选择。

It is not an easy answer, huh? Yet there is another option.

选项№2。您可以降低功耗,如果你缓解工作(其很明显,我知道)。首先,你不需要在你的应用程序每秒60帧。在质量设置寻找 Application.targetFrameRate VSYNC (请注意,垂直同步覆盖targetFrameRate)。其次,缓存结果。您可以pre-渲染复杂场景分为渲染目标,然后在屏幕上,而不是源场景present直至较大的变化将会作出修改。

Option №2. You can reduce power consumption if you ease the work (its obviously, I know). First, you don't need 60 frames per second in your app. Look for Application.targetFrameRate and vsync in quality setting (note that vsync overrides targetFrameRate). And second, cache your results. You can pre-render complex scene into render target and then present in on screen instead of source scene until considerably changes will be made.

这篇关于能源效率unity3d - 停止的应用程序等待用户交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆