Astra Child

How to connect and listen to the UIView stream

Estimated reading: 2 minutes 0 views


The example below shows how connect to the UIView stream and capture all the signals that are being sent. It also shows how to get the data payload out of the Signal.

using System;
using Doozy.Runtime.Signals;
using Doozy.Runtime.UIManager;
using Doozy.Runtime.UIManager.Containers;
using UnityEngine;
namespace Sandbox
    public class TestClass : MonoBehaviour
        private SignalReceiver m_Receiver;

        private void Awake()
            //initialize receiver and set callback
            m_Receiver = new SignalReceiver().SetOnSignalCallback(OnSignal);

        private void OnEnable()
            //connect receiver to the stream

        private void OnDisable()
            //disconnect receiver from the stream

        private void OnSignal(Signal signal)
            //ignore pings
            if (!signal.hasValue) return;

            //ignore if the payload type does not match
            if (!(signal.valueAsObject is UIViewSignalData data)) return;

            //get the view category
            string viewCategory = data.viewCategory;

            //get the view name
            string viewName = data.viewName;

            //get the view command
            switch (data.execute)
                case ShowHideExecute.Show:
                    //show command was issued
                case ShowHideExecute.Hide:
                    //hide command was issued
                case ShowHideExecute.InstantShow:
                    //instant show command was issued
                case ShowHideExecute.InstantHide:
                    //instant hide command was issued
                case ShowHideExecute.ReverseShow:
                    //hide command was issued (but it was already performing a show, thus a reverse show was triggered)
                case ShowHideExecute.ReverseHide:
                    //show command was issued (but it was already performing a hide, thus a reverse hide was triggered)
                    throw new ArgumentOutOfRangeException();
}Code language: PHP (php)
Share this Doc
Scroll to Top