Search Unity

Question How to use Live Capture to build PC applications

Discussion in 'Virtual Production' started by Astion, Nov 25, 2021.

  1. Astion

    Astion

    Joined:
    Mar 10, 2017
    Posts:
    3
    (I am sorry for my poor English ability)

    I loaded the Live Capture package with Unity 2021.2, and look forward to using Live Capture to build PC applications.
    I hope to use the Face Capture App in IOS to control the PC applications built by Unity.

    The CompanionAppServer class is private, I set it to public to create a server from a custom script. So I copied Live Capture as a custom package and changed the CompanionAppServer class.

    The following is my test code, which is added to the empty GameObject in the scene.
    Code (CSharp):
    1. using UnityEngine;
    2. using Unity.LiveCapture.CompanionApp;
    3. using Unity.LiveCapture;
    4.  
    5. public class TstServ : MonoBehaviour
    6. {
    7.     CompanionAppServer newSer;
    8.     void Start()
    9.     {
    10.  
    11.         var servMag = ServerManager.Instance;
    12.         newSer = (CompanionAppServer)servMag.CreateServer(typeof(CompanionAppServer));
    13.  
    14.         newSer.AutoStartOnPlay = false;
    15.  
    16.         newSer.Port = 8090;
    17.  
    18.         newSer.StartServer();
    19.     }
    20.     private void OnDestroy()
    21.     {
    22.         if (newSer)
    23.         {
    24.  
    25.             ServerManager.Instance.DestroyServer(newSer);
    26.             Debug.Log("Clean Server");
    27.         }
    28.     }
    29.     private void OnGUI()
    30.     {
    31.         if (newSer)
    32.         {
    33.             GUILayout.Label("PORT:" + newSer.Port.ToString());
    34.             GUILayout.Label("Running:" + newSer.IsRunning.ToString());
    35.         }
    36.         else {
    37.             GUI.color = Color.red;
    38.             GUILayout.Label("Server Not Found!");
    39.             GUILayout.Label("PORT:--");
    40.             GUILayout.Label("Running:--");
    41.         }
    42.     }
    43. }
    It can run normally in the editor .
    but in the built PC application, although Log shows that the server is already running, the server cannot be found in the Face Capture App.

    What i want to ask is
    1. Is the Face Capture App designed to only link with Unity Editor?
    2. Is the Live Capture package allowed to be built as a standalone PC application?
    3. I don't know much about network deployment, can anyone give me some reference to modify the Live Capture package so that it can be used on the built PC application?

    Above is my question, thanks for the help.
     
    Last edited: Nov 25, 2021
    kikesa72 likes this.
  2. ScottSewellUnity

    ScottSewellUnity

    Unity Technologies

    Joined:
    Jan 29, 2020
    Posts:
    20
    @Astion
    I can give some pointers regarding this.

    1. Yes, the app is only designed to work with the editor. It is theoretically possibly to use for other cases, but this is not officially supported at this time.
    2. Technically you can include the Live Capture package in a standalone build, but it is not officially supported at this time as there is still much work left to properly support this.

    That all said, if you really just want to communicate with app yourself, it is possible to use the CompanionAppServer and FaceClient classes directly by making them public.

    In your code above, you'll need to call CompanionAppServer.OnUpdate() in Update(), which is probably why it is not working. Otherwise, it looks fine to me at a quick glance.
     
    Miaopus, Yif1999 and Astion like this.
  3. Astion

    Astion

    Joined:
    Mar 10, 2017
    Posts:
    3
    It's awesome
    After testing it does work.
    Calling CompanionAppServer.OnUpdate() in Update() allows my packaged application to connect to IOS FaceCapture

    Thank you so much for helping me
     
  4. DanRP

    DanRP

    Joined:
    May 26, 2013
    Posts:
    33
    How do you set the CompanionAppServer class to public?
     
  5. Astion

    Astion

    Joined:
    Mar 10, 2017
    Posts:
    3
    I moved the LiveCapture package to my local project, and then added the "public" keyword to the CompanionAppServer class
     
    DanRP likes this.
  6. wartron

    wartron

    Joined:
    Jan 23, 2015
    Posts:
    8
    This is exactly what I had to do. Wish i found this thread earlier. But Yes copying the live-capture package from the packagecache into my assets and then making some classes public let me run the server in a standalone windows build.
     
  7. cameronkoyama

    cameronkoyama

    Joined:
    Sep 15, 2017
    Posts:
    1
    I'm trying to use this test code and have followed the steps of moving the LiveCapture package and adding public to the CompanionAppServer class but I am running into this error when I build and connect the Face Capture app. Does the FaceClient class need to be public as well? When I try to make it public it creates inconsistent accessibilities.
     

    Attached Files:

  8. kikesa72

    kikesa72

    Joined:
    Nov 20, 2015
    Posts:
    9
    AMAZING! Thanks!. I leave the updated code:

    using UnityEngine;
    using Unity.LiveCapture.CompanionApp;
    using Unity.LiveCapture;
    public class TstServ : MonoBehaviour
    {
    public CompanionAppServer newSer;
    void Start()
    {
    var servMag = ServerManager.Instance;
    newSer = (CompanionAppServer)servMag.CreateServer(typeof(CompanionAppServer));
    newSer.AutoStartOnPlay = false;
    newSer.Port = 8090;
    newSer.StartServer();
    }
    private void OnDestroy()
    {
    if (newSer)
    {
    ServerManager.Instance.DestroyServer(newSer);
    Debug.Log("Clean Server");
    }
    }
    private void OnGUI()
    {
    if (newSer)
    {
    GUILayout.Label("PORT:" + newSer.Port.ToString());
    GUILayout.Label("Running:" + newSer.IsRunning.ToString());
    }
    else
    {
    GUI.color = Color.red;
    GUILayout.Label("Server Not Found!");
    GUILayout.Label("PORT:--");
    GUILayout.Label("Running:--");
    }
    }
    void Update()
    {
    newSer.OnUpdate();
    }
    }
     
  9. najminoorzairul

    najminoorzairul

    Joined:
    Aug 14, 2023
    Posts:
    2
    hi, when i try to run my project using all the steps above, it seems to show errors, can someone help me?
     
  10. a878966424a

    a878966424a

    Joined:
    Dec 3, 2018
    Posts:
    1
    Due to an update in the Live Capture API after version 3.0, the solution is to change the previous ServerManager to ConnectionManager.
     
  11. kikesa72

    kikesa72

    Joined:
    Nov 20, 2015
    Posts:
    9
    Dont forget to move the live-capture folder from the library to the assets folder to u can modify the code and dont show errors.