private void OnUpdateComPortsList() { var p = SerialPort.GetPortNames(); if (p != null && p.Count() > 0) { Ports = p.ToList <string>(); } if (Ports.Count == 0) { eventAggregator.GetEvent <ComPortsNotFoundEvent>().Publish(null); logger.Log(Resources.PortsNotFound, Category.Debug, Priority.None); } else { StringBuilder sb = new StringBuilder(); for (int i = 0; i < Ports.Count(); i++) { sb.Append(Ports[i]); if (i != (Ports.Count() - 1)) { sb.Append(", "); } } logger.Log(string.Format(Resources.FoundTheFollowingPorts, sb.ToString()), Category.Debug, Priority.None); SelectedPortIndex = 0; } }
public void SetScript(MonoBehaviour newScript) { // If the script is null but we have some memory of the previous script... if (m_ScriptInternal == null && ScriptHashCode != default(int)) { // It is the same script! Assign it but don't clear ports // do nothing } // If we are overriding the script... else if (m_ScriptInternal != null && m_ScriptInternal.GetType() != newScript.GetType() || m_ScriptInternal == null && Ports.Count() > 0) { // Make sure to reset all dynamic ports! ClearDynamicPorts(); // Clear dictionary m_PortsPerFieldInfo.Clear(); } // Set the script m_ScriptInternal = newScript; // Update name name = m_ScriptInternal.GetType().Name + " (Script)"; // Update reference of type held ScriptHashCode = m_ScriptInternal.GetHashCode(); }