【问题标题】:Unity Android game: Screen turns off during gameplayUnity Android 游戏:游戏期间屏幕关闭
【发布时间】:2021-10-08 21:44:29
【问题描述】:

我之前在游戏中使用按钮来进行移动。现在我想使用加速度计进行运动。游戏玩法很棒,但是在游戏过程中屏幕会关闭。我用过

Screen.sleepTimeout = SleepTimeout.NeverSleep;

但它不起作用。我该如何解决这个问题?

【问题讨论】:

  • 我通过调用 Screen.sleepTimeout = SleepTimeout.NeverSleep;在唤醒()中。以前我在 Start() 中调用它。
  • 感谢您的回答。我会试试的。

标签: android unity3d


【解决方案1】:

我通过调用得到它的工作

Screen.sleepTimeout = SleepTimeout.NeverSleep;在 Awake() 方法中。

之前我在 Start() 方法中调用它。

【讨论】:

    【解决方案2】:

    这样试试,

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class SleepDemo : MonoBehaviour
    {
        void Awake() {
            Screen.sleepTimeout = SleepTimeout.NeverSleep;
        }
    
        // Start is called before the first frame update
        void Start(){   
        }
    
        // Update is called once per frame
        void Update(){   
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-02-10
      • 2013-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-28
      • 2014-12-19
      • 1970-01-01
      相关资源
      最近更新 更多