/// <summary> /// Set the information of the one that is on top /// Move all the other objects down /// </summary> /// <param name="newInfoObject">The object that we want to tell the player about</param> public void AddInfo(Source_Packet newInfoObject) { // Return if we are not showing if (!isShowing) { return; } if (newInfoObject.destIpInt == 0 || newInfoObject.sourceIpInt == 0) { return; } // I need to move all of the objects down by a certain amount for (int i = 0; i < rectTransforms.Length; i++) { // Get a reference to the variable newPos = rectTransforms[i].anchoredPosition; // Alter the value newPos.y += movementAmount; // If the new position is past the bottom, then just move // this object to the top if (newPos.y < bottomYCoord) { newPos.y = topYCoord; // Change the value of this one, because it is the most recent infoObjects[i].SetText(newInfoObject); } // Set the transform component rectTransforms[i].anchoredPosition = newPos; } }
/// <summary> /// Take in a source object, and set it's integer values /// </summary> /// <param name="FilebeatSource"></param> private void SetIntegerValues(Source_Packet packetbeatSource) { // Calculate the INTEGER version of the SOURCE IP address packetbeatSource.sourceIpInt = IpToInt(packetbeatSource.packet_source.ip); // Calculate the INTEGER version of the DESTINATION IP address packetbeatSource.destIpInt = IpToInt(packetbeatSource.dest.ip); }
/// <summary> /// Set the text of this object /// </summary> /// <param name="data">The info from a packet</param> public void SetText(Source_Packet data) { try { protocol.text = data.transport; string[] goodTimes = data.timestamp.Split('T'); timestamp.text = goodTimes[1]; source.text = data.packet_source.ip; dest.text = data.dest.ip; port.text = data.dest.port.ToString(); } catch { // Debug.Log(e.Message); } }