public static void Received(OSCEditorReceiver receiver, IOSCPacket packet)
        {
            var message = new OSCConsolePacket();

            message.Info       = $"<color=green>Editor Receiver</color>: {receiver.LocalPort}. From: {(packet.Ip != null ? packet.Ip.ToString() : "Debug")}";
            message.PacketType = OSCConsolePacketType.Received;
            message.Packet     = packet;

            Log(message);
        }
Exemple #2
0
        public static OSCEditorReceiver CreateEditorReceiver()
        {
            var receiver = new OSCEditorReceiver();

            receiver.LocalHostMode = OSCLocalHostMode.Any;
            receiver.LocalHost     = OSCUtilities.GetLocalHost();
            receiver.LocalPort     = 7100 + _receivers.Count;

            _receivers.Add(receiver);

            return(receiver);
        }
Exemple #3
0
        public static void RemoveEditorReceiver(OSCEditorReceiver receiver)
        {
            if (!_receivers.Contains(receiver))
            {
                return;
            }

            receiver.Close();
            receiver.Dispose();

            _receivers.Remove(receiver);
        }
Exemple #4
0
        public static void LoadSettings()
        {
            if (!File.Exists(_configsPath))
            {
                return;
            }

            var configs = JsonUtility.FromJson <OSCEditorConfigs>(File.ReadAllText(_configsPath));

            _receivers.ForEach(receiver =>
            {
                receiver.Close();
                receiver.Dispose();
            });
            _receivers.Clear();

            _transmitters.ForEach(transmitter =>
            {
                transmitter.Close();
                transmitter.Dispose();
            });
            _transmitters.Clear();

            foreach (var receiverConfig in configs.Receivers)
            {
                var receiver = new OSCEditorReceiver();
                receiver.LocalHostMode = receiverConfig.LocalHostMode;
                receiver.LocalHost     = receiverConfig.LocalHost;
                receiver.LocalPort     = receiverConfig.LocalPort;

                if (receiverConfig.AutoConnect)
                {
                    receiver.Connect();
                }

                _receivers.Add(receiver);
            }

            foreach (var transmitterConfig in configs.Transmitters)
            {
                var transmitter = new OSCEditorTransmitter();
                transmitter.RemoteHost    = transmitterConfig.RemoteHost;
                transmitter.RemotePort    = transmitterConfig.RemotePort;
                transmitter.UseBundle     = transmitterConfig.UseBundle;
                transmitter.LocalHostMode = transmitterConfig.LocalHostMode;
                transmitter.LocalHost     = transmitterConfig.LocalHost;
                transmitter.LocalPortMode = transmitterConfig.LocalPortMode;
                transmitter.LocalPort     = transmitterConfig.LocalPort;

                if (transmitterConfig.AutoConnect)
                {
                    transmitter.Connect();
                }

                _transmitters.Add(transmitter);
            }

            foreach (var componentConfig in configs.Components)
            {
                var componentType = OSCEditorUtils.GetTypeByGUID(componentConfig.Guid);
                if (componentType == null || !componentType.IsSubclassOf(typeof(OSCEditorComponent)))
                {
                    componentType = typeof(OSCEditorManager).Assembly.GetType(componentConfig.Type);
                    if (componentType == null)
                    {
                        continue;
                    }
                }

                var component = GetComponent(componentType);
                if (component == null)
                {
                    continue;
                }

                if (component is OSCEditorReceiverComponent receiverComponent)
                {
                    receiverComponent.Receiver = GetEditorReceiver(componentConfig.Index);
                }
                else
                {
                    if (component is OSCEditorTransmitterComponent transmitterComponent)
                    {
                        transmitterComponent.Transmitter = GetEditorTransmitter(componentConfig.Index);
                    }
                }

                component.Active = componentConfig.Active;
            }
        }