• 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 Lukas1 · Sep 06, 2013 at 08:06 AM · iosobjective-cqcarscreen orientation

iPhone - screen gets black when changing rotation while Unity is paused

I have a unity app, that uses Vuforia AR library. I extended this app with some iOs code. I wanted to be able to display my custom UIViewControllers sometimes instead of the main view controller that Unity uses. But I want to be able to switch back. I.e: I have a button that opens UIViewController with "About app" information and this controller then has "Exit" button to return to Unity controller.

This is my code for adding the new controller instead of the Unity View Controller:

 self.unityRootController = self.keyWindow.rootViewController; // keep reference to the Unity Controller
 self.keyWindow.rootViewController = controller; // display my own controller

 // this pauses the unity and qcar -> so that QCAR doesn't try to recognize objects, when Unity Controller is not up
 QCARUnityPlayer::getInstance().QCARPause(true);
 UnityPause(true);

Then when returning from my own controller to Unity controller:

 self.keyWindow.rootViewController = self.unityRootController; // return to Unity Controller
 
 // start tracking with QCAR and unpause Unity View
 QCARUnityPlayer::getInstance().QCARPause(false);
 UnityPause(NO);

This works fine except one case, that's caused me to pull my hair ever since encountering it. My app supports changing orientation of screen in both Unity and ObjectiveC code. And this is the trouble: If I open my View Controller while the device is for example in Portrait Orientation, then turn the device to Landscape orientation, my controller gets correctly rotated. But if I at this moment want to close my custom view controller and return to unity controller, the screen gets black suddenly. After rotating the device to portrait orientation, the unity controller suddenly starts working as expected.

I'd like the unity controller to start directly after closing my custom view controller even if the screen orientation is changed. I suppose I have to add some code after I start again the Unity Player here:

 QCARUnityPlayer::getInstance().QCARPause(false);
 UnityPause(NO);
 // TODO: supposedly some code should go here, that fixes black screen

But I tried to find something in the AppController.mm, that is builded by Unity and I could not find anything, that would help me. I found few lines of unity code, that had the word "orientation" in it, but I tried to use that code and didn't help. Does anybody know, what should I do, please? Thanks a bunch :)

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

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

15 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

Related Questions

Passing NSDictionary from obj-C to C# 3 Answers

qcar unity project for android and ios 1 Answer

Returning a byte array from ObjC to C# script on ios 1 Answer

iOS Facebook integration issue. 0 Answers

How to create an iOS plugin that takes recordings from the mic and plays it back through the speaker (live)? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges