Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cannot find a way to add Custom UI Controls in Render streaming

Discussion in 'Unity Render Streaming' started by pikachuxxx, Nov 3, 2020.

  1. pikachuxxx

    pikachuxxx

    Joined:
    Jan 22, 2019
    Posts:
    17
    So we started working with WebRTC and the document was hellish but we managed to get the examples working, We are trying to add our own controls on the HTML website to control other stuff as well other than the lights and we cannot find any way to do so. Any help on properly configuring the WebRTC and adding custom UI controls would be extremely helpful. Do ask for any additional information.
     
  2. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
    The html buttons are here in the webserver code:

    https://github.com/Unity-Technologies/UnityRenderStreaming/blob/develop/WebApp/public/scripts/app.js
    As of 11/04/2020 look for the 'onClickPlayButton' function.

    Walk that code to register-events.js, 'sendClickEvent' :
    https://github.com/Unity-Technologi...elop/WebApp/public/scripts/register-events.js

    This will be sending three bytes - a data type (uint8) and a value (int16).
    These will be received on the Unity side and passed to RemoteInput's 'ProcessInput':

    https://github.com/Unity-Technologi...derstreaming-hd/Assets/Scripts/RemoteInput.cs

    The specific switch block is:

    case EventType.ButtonClick:
    var elementId = BitConverter.ToInt16(bytes, 1);
    ProcessButtonClickEvent(elementId);
    break;


    'ProcessButtonClickEvent' eventually triggers one of the actions specified from the inspector on RenderStreaming in the arrayButtonClickEvent variable:

    https://github.com/Unity-Technologi...treaming-hd/Assets/Scripts/RenderStreaming.cs

    Attempt to add a new button to the webserver, then hook up a new action on the Unity side. You can see from there you can start to send our own packets of data for custom functionality.
     
  3. UnityLoverr

    UnityLoverr

    Joined:
    Mar 29, 2021
    Posts:
    10
    Your links dont work anymore...
     
  4. Maktech

    Maktech

    Joined:
    Jan 15, 2015
    Posts:
    31
    Asraas likes this.