Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by NGC6543 · Jan 30, 2016 at 07:19 AM · iosscreen

Turn on/off iOS device's screen via script?

Hi, is there a way to turn on/off an iOS devices' screen via c# script?

What I want to do is to turn the screen off when it is not in use(for example the device is placed on a surface), but keep the application running, and turn the screen on if the device is in use later.

For iOS device if the screen is turned off, it means the device is in 'stand-by' state so you have to manually turn it on by pressing the home button or the power button, and unlock the phone. I don't want the device to be locked when the screen is off, but I don't know how and I don't think Apple offers that functionality. I'm just curious if anyone came up with a solution or something(like jail-breaking).

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Addyarb · Jan 30, 2016 at 08:43 AM

Kind of a hacky solution, but the first thing that comes to mind is:

  1. Create a black texture that fills the screen and set it's alpha to 0 (100% transparent).

  2. Use the front camera and GetPixels to check if most of the pixels are black (i.e. the camera is facing down against a table or something).

  3. Enable the black screen if step 2 is true.

  4. Periodically (using coroutine) check if pixels are not mostly black, and "wake the app up" by then slowly fading out the black screen alpha.

Of course, you'll want to create a bool called something like "isSleeping" and call it if the phone is "sleeping." Then, set all of your rendering to very low quality to save as much battery as possible. At the minimum, I would put a null check in every Update function.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image NGC6543 · Jan 30, 2016 at 01:41 PM 0
Share

That can be one solution, but it does not 'turn off' the screen. I'm using the device's gyro sensor to check the motion at the moment, and it's much cheaper and faster than checking camera's pixel values. Devices get hot when the screen and backlight are on, and doing so can be a major bottleneck because the devices automatically cut the performance to cool down.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

38 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Can't run ANYTHING on iOS. No error messages! 0 Answers

Black screen while running in iOS 4 Answers

Device Auto-Rotation 1 Answer

Cannot run anything in iOS. No errors! 0 Answers

How to obtain physical screen size in iOS simulator? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges