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 Guy-Corbett · Apr 15, 2016 at 08:11 AM · androiduicrashwebcamtexturelock

UI and WebCamTexture problems when Android lock screen is shown

Hey there,

I've already asked a question about how to get the android lock screen enabled in dev builds because I need to debug an issue which only occurs when the lock screen is shown. However I thought I ask if anyone knows how to just solve the problems I'm having.

I'm almost certain it has something to do with the WebCamTexture as, in most parts of my app, I can lock then unlock the device just fine. In the one part which uses a WebCamTexture to show the feed from the device's camera on screen, things go wrong.

What tends to happen is that once I unlock, the app resumes but some of my UI elements are missing. Specifically the RawImage displaying the WebCamTexture is missing as are any UI elements in the same level of the Unity Editor's hierarchy or lower. UI elements higher up the hierarchy are present and correct. In my case this means before I lock the device I can see this;

alt text

An exit button in the top left, my WebCamTexture center, and two buttons along the bottom. However after I unlock the screen I see this;

alt text

All the UI bar the exit button is missing. Sometimes the app continues to work though all I can do his hit the exit button. Sometimes it crashes shortly after. I've tried my best to work around the problem by disabling the WebCamTexture when the lock occurs and so on but so far I've had no luck.

Any advice would be gratefully received.

2.png (89.7 kB)
1.png (403.4 kB)
Comment
Add comment · Show 1
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 Guy-Corbett · Apr 15, 2016 at 07:28 AM 0
Share

Right, no sooner do I post this than I find a solution.

I just changed how I'm stopping the WebCamTexture when the device locks and now it's working. Still this feels like a pretty work around and that I could be missing something, so I'll leave the question open in case anyone has a better solution. For anyone who is interested I've solved it by doing this.

     void OnDisable()
     {
         $$anonymous$$illWebcam();
     }
 
     void OnApplicationPause(bool paused)
     {
         if (paused)
         {
             $$anonymous$$illWebcam();
         }
     }
 
     void OnApplicationFocus(bool focused)
     {
         if (!focused)
         {
             $$anonymous$$illWebcam();
         }
     }
 
     private void $$anonymous$$illWebcam()
     {
         if (m_webcamTexture != null)
         {
             m_cameraImage.texture = null;
             m_webcamTexture.Stop();
             m_webcamTexture = null;
         }
     }

Though obviously that needs to be coupled with code which sets the webcam up again when the device unlocks.

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

WebCamTexture crashes on android 0 Answers

Input field crashes on Android 4.1.2 (Unity 5.1.1f1) 0 Answers

How do I enable the Android lock screen in developer mode? 1 Answer

Random crashes in Android build 0 Answers

WebCamTexture and Nexus 6p 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