Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Android application on multiple displays

Discussion in 'Android' started by luca_digennaro, Apr 9, 2018.

  1. luca_digennaro

    luca_digennaro

    Joined:
    Sep 7, 2017
    Posts:
    3
    Hi everyone,

    I have an Android tablet application already connected via Bluetooth with another one on a mobile.
    I need to put a specific view from the tablet (i.e. everything but the UI) to an external monitor.

    So, the complete chain is:

    MOBILE (connected via Bluetooth to) TABLET (connected via something to) EXTERNAL MONITOR.

    I'm currently using nativebt plugin for the Bluetooth connection, so as far as I know I can't use an additional Bluetooth connection on the external monitor.

    My thought was a physical cable, but I'm not sure I can address different renderings to multiple displays on Android.

    Here I undestand I can't:
    https://docs.unity3d.com/Manual/MultiDisplay.html

    while here i understand I can:
    https://docs.unity3d.com/ScriptReference/Display.html

    Any idea?
     
  2. adblanchot

    adblanchot

    Joined:
    Mar 8, 2019
    Posts:
    1
    Did you find your answer?
     
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You'll need an HDMI cable from the Tablet to the monitor, I doubt Bluetooth or WiFi would be fast enough, but you could try Chromecast too.
     
  4. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,165
    Casting to another display works pretty well as a second display, even via wifi.
     
  5. lucianoreul

    lucianoreul

    Joined:
    Apr 6, 2017
    Posts:
    2
    I need to stream the display from my Android device application to a projector with WiFi, could you tell me an easier way?
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You might try Relector https://www.airsquirrels.com/reflector
     
  7. Francois_Chene

    Francois_Chene

    Joined:
    Sep 15, 2015
    Posts:
    2
    A bit late in the game but if anyone else is looking: recent android devices and displays supports Miracast or a variant (e.g. Samsung's SmartView) so it's pretty straightforward. Sometime the screen mirroring activation is a bit buried in the devices parameters, but you can start the whole thing by code with a simple native call (see here).

    Back to the original question: in 2018.3.12, once the screen mirroring is activated you can very easily able to have different content on the device and on the external monitor using the Display class. In my case, I used a camera to grab the content I wanted to display on the tv screen. These few line of code did the trick:

    Code (CSharp):
    1. if (Display.displays.Length <= 1) return;
    2.  
    3.             Display tv = Display.displays[1];
    4.          
    5.             tv.SetRenderingResolution(1280, 720);
    6.             _CastCam.SetTargetBuffers(tv.colorBuffer, tv.depthBuffer);
    Sadly, in 2019 this code doesn't work anymore as Display.displays.Length remains at 1.
     
  8. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,165
    @Francois_Chene please submit a bug report, attach your project and include details about the hardware, and then post the bug # here. Thanks!
     
  9. Francois_Chene

    Francois_Chene

    Joined:
    Sep 15, 2015
    Posts:
    2
    I made a sample project for the bug report (first in 2018.3.12f1 that I upgraded to 2019.2.12f1) and the issue did not occur.

    I made a bit of digging and found out the culprit: the "Graphics API" default values (in the player settings) for a new 2019.2.12f1 project have "Vulkan" listed first. Changing the API orders or enabling "Auto Graphics API" solves the issue for 2019.2.12f1 and setting Vulkan as the first API in 2018.3.12f1 creates the issue.

    TL;DR: having different content on different displays does not work with Vulkan on Android, regardless of version.

    Bug ID is #1198601
     
  10. xzodia

    xzodia

    Joined:
    Jan 24, 2013
    Posts:
    50
    I am experiencing the same problem with iOS Metal (Airplay).
     
    Last edited: Nov 15, 2019