Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Prevent screen from turning off on PC/Mac (non-mobile)

Discussion in 'Scripting' started by virgiliu, Feb 8, 2017.

  1. virgiliu

    virgiliu

    Joined:
    Apr 4, 2015
    Posts:
    46
    Our game uses a custom, non-conventional input method that reads data from a USB dongle and then moves the character based on that data. No input comes from keyboard, mouse or a game controller.

    The problem we're faced with is that players' screen turns off because their OS doesn't detect any user interaction and thinks they're AFK.

    I've found Screen.sleepTimeout but the documentation says it has no effect on non-mobile platforms, and we're on PC & Mac (https://docs.unity3d.com/ScriptReference/Screen-sleepTimeout.html)

    The build has "run in background" enabled.

    Is there any way to prevent monitor from sleeping or screensaver from starting?