Пример #1
0
        /// <summary>
        ///     Sends a <see cref="NetworkPackage" /> to all specified receivers.
        /// </summary>
        /// <param name="pkg">
        ///     <see cref="NetworkPackage" /> to send.
        /// </param>
        public void Send(INetworkPackage pkg)
        {
            if (_client == null)
            {
                // Do NOT call AciLog here to prevent looped method call
                Debug.unityLogger.LogWarning(GetType().Name, "Not properly initialized. Please call the Initialize() method before sending data.");
                return;
            }

            string json = JsonConvert.SerializeObject(pkg);

            // Do NOT call AciLog here to prevent looped method call
            Debug.unityLogger.Log(GetType().Name, "Sending package \"" + json + "\"");
            try
            {
                // Convert to binary
                byte[] data = Encoding.UTF8.GetBytes(json);
                for (int i = 0; i < _remoteEndPoints.Length; ++i)
                {
                    // Send msg to receiver
                    _client.Send(data, data.Length, _remoteEndPoints[i]);
                }
            }
            catch (Exception err)
            {
                AciLog.LogError(GetType().Name, err);
            }
        }
        private void EvaluateVisibility(SerializedProperty property)
        {
            string path = property.propertyPath.Contains(".")
                ? System.IO.Path.ChangeExtension(property.propertyPath, m_Attr.conditionName)
                : m_Attr.conditionName;

            m_Property = property.serializedObject.FindProperty(path);
            switch (m_Property.type)
            {
            case "bool":
                m_Hidden = m_Property.boolValue.Equals(m_Attr.conditionValue);
                return;

            case "int":
                m_Hidden = m_Property.intValue.Equals(m_Attr.conditionValue);
                return;

            case "long":
                m_Hidden = m_Property.longValue.Equals(m_Attr.conditionValue);
                return;

            case "float":
                m_Hidden = m_Property.floatValue.Equals(m_Attr.conditionValue);
                return;

            case "double":
                m_Hidden = m_Property.doubleValue.Equals(m_Attr.conditionValue);
                return;

            case "Enum":
                m_Hidden = m_Property.enumValueIndex.Equals((int)m_Attr.conditionValue);
                return;

            case "string":
                m_Hidden = m_Property.stringValue.Equals(m_Attr.conditionValue);
                return;

            case "Vector2":
                m_Hidden = m_Property.vector2Value.Equals(m_Attr.conditionValue);
                return;

            case "Vector3":
                m_Hidden = m_Property.vector3Value.Equals(m_Attr.conditionValue);
                return;

            default:
                AciLog.LogError("HidePropertyIfDrawer",
                                $"Trying to compare a property {m_Property.name} of type {m_Property.type} failed.");
                m_Hidden = false;
                return;
            }
        }
Пример #3
0
        /// <summary>
        ///     Initializes the network connection for sending data
        /// </summary>
        private void Initialize()
        {
            if (ips.Length != ports.Length)
            {
                AciLog.LogError(GetType().Name,
                                "IP/Port mismatch. Please check the configuration of the NetworkPublisher.");
            }

            _remoteEndPoints = new IPEndPoint[ips.Length];
            for (int i = 0; i < ips.Length; ++i)
            {
                _remoteEndPoints[i] = new IPEndPoint(IPAddress.Parse(ips[i]), ports[i]);
                AciLog.Log(GetType().Name, "Sending packages to " + ips[i] + " : " + ports[i]);
            }

            _client = new UdpClient();
        }
Пример #4
0
 public void SendError()
 {
     AciLog.LogError("LogTester", "This is a test error.");
 }