Ejemplo n.º 1
0
        /// <summary>
        /// Appends the data.
        /// Depending on your bundle mode the AppendData method works in a different way.
        /// If you use bundles you can append multiple OscMessages.
        /// If you don't use bundles (default) you append data to your OscMessage
        /// We only can append data types that are supported by the OSC specification:
        ///(Int32,Int64,Single,Double,String,Byte[],OscTimeTag,Char,Color,Boolean)
        /// </summary>
        /// <param name="_data">_data.</param>
        public void AppendData(object _data)
        {
            OscBundle bundle = _data as OscBundle;

            // Debug.Log("UniOSCEventDispatcherCB.AppendData:" + (bundle != null).ToString());
            if (_OSCpkg == null)
            {
                // if (bundle == null) { _SetupOSCMessage(false); } else { _SetupOSCMessage(true); }
                _SetupOSCMessage(bundle != null);
                // return;
            }

            if (_OSCpkg is OscBundle)
            {
                if (bundle == null)
                {
                    if (_data is OscMessage)
                    {
                        ((OscBundle)_OSCpkg).Append(_data);
                    }
                    else
                    {
                        Debug.LogWarning("<color=orange>You can only append a OscMessage to a OscBundle</color>");
                    }
                }
                else
                {
                    Debug.LogWarning("<color=orange>You  can't append a OSCBundle to a OSCBundle</color>");
                }
            }

            if (_OSCpkg is OscMessage)
            {
                if (bundle == null)
                {
                    if (_data is OscMessage)
                    {
                        Debug.LogWarning("<color=orange>You can't append a OSCMessage to a OSCMessage</color>");
                    }
                    else
                    {
                        _OSCpkg.Append(_data);
                    }
                }

                else
                {
                    Debug.LogWarning("<color=orange>You can't append a Bundle to a OSCMessage</color>");
                }
            }
        }