Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Unity 4.1 Airplay: missing docs

Discussion in 'iOS and tvOS' started by Alexey, Mar 24, 2013.

  1. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,384
    it was brought to our attention that some Display class members are not documented. While it is straightforward to deduce their meaning - it is hard to do when you dont know what are you looking for ;-)
    here they are:
    int renderingWidth, renderingHeight
    these are the the rendering resolution
    int systemWidth, systemHeight
    these are real display resolution
    ** An example: if you grab 1080p display and call SetRenderingResolution(256,256), then renderingWidth/Height will be 256x256 and system ones will be 1920x1080
    RenderBuffer colorBuffer, depthBuffer
    these are OpenGL ES buffers that you should use to render to this display. Use in conjunction with Camera.SetTargetBuffers.
    Also, please check usage sample here:
    http://docs.unity3d.com/Documentation/ScriptReference/Display.html
     
  2. JarJarThomas

    JarJarThomas

    Joined:
    Mar 24, 2012
    Posts:
    2
    Ok and how do i assign a camera to a specific display ?
     
  3. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,384
  4. Skyrise

    Skyrise

    Joined:
    Nov 3, 2005
    Posts:
    158
    Don't know if it's a bug or a limitation currently and don't know if it's the right place to ask but...

    Got AirPlay working very fast on our game (forma.8) yesterday, very easy following the documentation, however I have a problem: we use three camera in the game right now and I have no problem in using them on the main display, but when mirroring we can only output one single camera on the external display but not a second one. When we switch off the mirroring and reassign in code the camera to the main display everything works as supposed.

    Basically we need to have two cameras rendered on the external display (game + HUD), and one on the main display when mirroring (another part of the HUD), but after trying everything possible I can only get one camera to render properly on the external display.

    Any idea? :)
     
  5. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,384
    I cant understand what you are trying to do (maybe too many letters before first coffee ;-)). Can you please bug report with small repro project? As i understand you dont need to draw all your game to show the bug, right?
     
  6. Skyrise

    Skyrise

    Joined:
    Nov 3, 2005
    Posts:
    158
    Ok nevermind... it was a mistake on my part, a stupid syntax error! Too much code to crunch in two days and I missed it! :(

    For anyone who needs it, that's the code snippet we are using for mirroring the game (three cameras: game, hud and game map, when mirroring only the map shows in the iPad display), derived from the documentation and from here:

    http://drawlogic.com/2013/03/14/unity-4-1-apple-tv-airplay-and-the-new-consoles/

    Just call DualDisplay() in an Invoke or Update.

    Code (csharp):
    1.  
    2.  
    3. var mainCamera : Camera;
    4. var hudCamera : Camera;
    5. var mapCamera : Camera;
    6.  
    7. function DualDisplay() {
    8.  
    9.     if ( Display.displays.Length > 1  ) {
    10.  
    11.  
    12.                     var secondDisplay : Display = Display.displays[1];
    13.                    
    14.                     Display.displays[1].SetRenderingResolution(1280,720);
    15.                     Display.displays[0].SetRenderingResolution(2048,1536);
    16.                    
    17.                     mapCamera.SetTargetBuffers (Display.main.colorBuffer, Display.main.depthBuffer);
    18.                     hudCamera.SetTargetBuffers (secondDisplay.colorBuffer, secondDisplay.depthBuffer);
    19.                     mainCamera.SetTargetBuffers (secondDisplay.colorBuffer, secondDisplay.depthBuffer);
    20.                    
    21.     }
    22.                 else
    23.                
    24.         {
    25.  
    26.                     Display.displays[0].SetRenderingResolution(2048,1536);
    27.                     mapCamera.SetTargetBuffers (Display.main.colorBuffer, Display.main.depthBuffer);
    28.                     hudCamera.SetTargetBuffers (Display.main.colorBuffer, Display.main.depthBuffer);
    29.                     mainCamera.SetTargetBuffers (Display.main.colorBuffer, Display.main.depthBuffer);
    30.  
    31.                 }
    32.                
    33.  
    34. }
     
  7. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,161
    Works (with Airserver), but looks terribly aliased.
    Is there a way to get AntiAlias for the secondary display?
     
  8. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,384
    well, there are ways yes, but all too hackish. I would say it sounds weird - did you try setting bigger res?
     
  9. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Anybody can help me to understand how AirPlay Mirroring works?

    If you connect iPad to AirPlay, the iPad is calculate everything for 2 monitor?

    So mirroring cut to half performance if I not disable the camere from one monitor ...

    It is right?
     
  10. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Up
     
  11. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,161
    No, there´s no noticable slowdown on the framerate.
    You can define what exactly will be send to the external screen by telling the app what camera should be taken.
    If you don´t do any of these changes, the whole app will be send, as every other app will.
     
  12. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Ok so if I send one camera (it is the same) on 2 different monitor there is any slowdown on FPS?
     
  13. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,161
    I would say: No slowdown
     
  14. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Dear support,

    about 2 hours I try to use AppleTV with my application(build with Unity 4.1.2f4) using AngryAnt gits source https://gist.github.com/AngryAnt/5160204.

    As you can read in gits other users comment, also I encountered in display.Lenght = 1 Problem.

    Unity render my camera in another buffer but cannot stream the content on my TV.

    Any solution?
     
    Last edited: Jul 25, 2013
  15. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,161
    Just for your information:
    As far as I know AppleTV and AirPlay are two different things. I haven´t tried AppleTV yet, but AirPlay is really easy:
    Use the script above to define what camera will be sent.
    Connect via WLAN to a PC/Mac where AirServer (www.airserver.com) is running.
    The Airplay symbol appears on your device when you are connected. Hit this symbol to start streaming.
     
  16. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    http://www.apple.com/appletv/airplay/

    As you can see on Apple website, the AirPlay stream videocontent via AppleTV ...

    If I use simple default AirPlay mirroring, All works correctly.

    But the problem is Unity Display detection ...

    I need to split my cameras on two display (GUI on Ipad and Main camera on TV like "MetalStorm: Wingman") but Display.display.Lenght = 1 ...So Unity cannot found second monitor ...

    Thanks
     
    Last edited: Jul 26, 2013
  17. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    118
    Hello Cascho01,

    How would I do that?
    How would I send one camera to two displays, as SetTargetBuffers can only take one color/depth buffer?
    I'm trying to get a camera to display on both the device and the external screen.

    Thanks for your help!
     
  18. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,161
    If you just want to get the iPad-Screen mirrored to an external screen you don´t have to do anything in Unity:
    Connect via WLAN to a PC/Mac where AirServer (www.airserver.com) is running.
    The Airplay symbol appears on your device when you are connected. Hit this symbol to start streaming.
     
  19. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    118
    Hi,
    I don't see anything on assigning a camera to several display.
    I want to display on both the device AND the external screen.
    Is there a way to do that?
    Thank you!
     
  20. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    118
    No, I want ONE camera to display on both screens, not the whole game.
    I know the whole game is mirrored when I don't do anything on any cameras, but when I call SetTargetBuffers on one camera, every camera starts being displayed on only one screen.
    I have cameras that need to be displayed on the device (buttons...), cameras to be displayed on the TV (the game scene), AND cameras to be displayed on both.
    Is there a way to do that without duplicating cameras?

    Thanks for your answer!
     
  21. kaz2057

    kaz2057

    Joined:
    Jan 18, 2011
    Posts:
    326
    Anyone is ablet to active AA on Secondary Display?

    Thanks
     
  22. rohKan

    rohKan

    Joined:
    Sep 24, 2012
    Posts:
    8
    Hi Cascho01,
    Did you find a solution to this, i.e. Anti Aliasing to the secondary display?
     
  23. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,161
    Sorry, no
     
  24. rohKan

    rohKan

    Joined:
    Sep 24, 2012
    Posts:
    8
    Well i was able to get 70% better anti-aliasing on my Windows system on which i installed the Air Server.
    It has a Nvidia graphics card . I enabled anti-aliasing in the "Nvidia control panel" in the control panel.
    Hope this helps.
     
  25. nm8shun

    nm8shun

    Joined:
    Jul 14, 2007
    Posts:
    476
    I know this is an old post...but thanks so very much for sharing. Works very well and I'd been working forever to get it working. Thanks much!
     
  26. niall1111

    niall1111

    Joined:
    Nov 29, 2013
    Posts:
    14
    Sorry to bump the old post again, but I've been banging my head against Airplay for a day now, can't seem to find what I'm looking for. We don't want our users to have to enable mirroring on their device in order for airplay to work. Is that possible? The post on drawlogic seems to imply it can be done with some native code, but I can't seem to find anyone who's actually done that. My Obj-C knowledge is limited at best, so before I go diving into that mess, I'd like to know for sure that's even possible.

    Essentially we have a video player as part of the app, using VideoTexturePro to render H.264 video files that have been downloaded to device. I need to add an Airplay button to the UI for the video player. "Easy enough, Unity has this Display class, specifically for Airplay", says the naive Niall. But it turned out Display.displays.Length is always 1 unless you turn on mirroring outside of the app? I've seen what i'm looking for in other apps, presumably XCode native apps, but who knows. So I guess the big question would be, "Is it possible to detect Airplay devices in a Unity app without the user enabling mirroring outside of the app?"

    Any pointers as to how that might be done would also be amazing. Thanks!
     
  27. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,384
  28. niall1111

    niall1111

    Joined:
    Nov 29, 2013
    Posts:
    14
    So are you saying it's literally impossible with Unity? The iOS netflix app does exactly what I describe, though it's obviously not built in Unity. Perhaps it's possible with something like the U3DXT plugin? Though of course their site has been down since last night! :)
     
  29. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,384
    >>The iOS netflix app does exactly what I describe, though it's obviously not built in Unity.
    the problem is - there is no official way to do it. Or rather last time i checked i didnt find any (apart from using private frameworks).
     
unityunity