私のXMLの一部は次のようになります。
<IOConfig>
<Packet Name="PacketOut" RemoteAddress="10.0.2.223" RemotePort="2020" NetworkInterface="ETH0">
<Signal Type="float" Name="x_out" Unit="m/s" Routing="" UnityObject="CraneBoom" UnityName="Out" NetworkConvert="1"></Signal>
<Signal Type="float" Name="y_out" Unit="m/s" Routing="" UnityObject="CraneBoom" UnityName="Out" NetworkConvert="1"></Signal>
<Signal Type="float" Name="z_out" Unit="m/s" Routing="" UnityObject="CraneBoom" UnityName="Out" NetworkConvert="1"></Signal>
<Signal Type="float" Name="alpha_out" Unit="m/s" Routing="" UnityObject="CraneBoom" UnityName="Out" NetworkConvert="1"></Signal>
<Signal Type="float" Name="theta_out" Unit="m/s" Routing="" UnityObject="CraneBoom" UnityName="Out" NetworkConvert="1"></Signal>
<Signal Type="float" Name="phi_out" Unit="m/s" Routing="" UnityObject="CraneBoom" UnityName="Out" NetworkConvert="1"></Signal>
<Signal Type="float" Name="x_out1" Unit="m/s" Routing="" UnityObject="CraneSlewing" UnityName="Out1" NetworkConvert="1"></Signal>
<Signal Type="float" Name="y_out1" Unit="m/s" Routing="" UnityObject="CraneSlewing" UnityName="Out1" NetworkConvert="1"></Signal>
<Signal Type="float" Name="z_out1" Unit="m/s" Routing="" UnityObject="CraneSlewing" UnityName="Out1" NetworkConvert="1"></Signal>
<Signal Type="float" Name="alpha_out1" Unit="m/s" Routing="" UnityObject="CraneSlewing" UnityName="Out1" NetworkConvert="1"></Signal>
<Signal Type="float" Name="theta_out1" Unit="m/s" Routing="" UnityObject="CraneSlewing" UnityName="Out1" NetworkConvert="1"></Signal>
<Signal Type="float" Name="phi_out1" Unit="m/s" Routing="" UnityObject="CraneSlewing" UnityName="Out1" NetworkConvert="1"></Signal>
</Packet>
<Packet Name="PacketIn" LocalPort="2021" NetworkInterface="ETH0">
<Signal Type="float" Name="x_in" Unit="m/s" Routing="" UnityObject="CraneBoomCrash" UnityName="collider1" NetworkConvert="1"></Signal>
<Signal Type="float" Name="y_in" Unit="m/s" Routing="" UnityObject="CraneBoomCrash" UnityName="collider1" NetworkConvert="1"></Signal>
<Signal Type="float" Name="z_in" Unit="m/s" Routing="" UnityObject="CraneBoomCrash" UnityName="collider1" NetworkConvert="1"></Signal>
<Signal Type="float" Name="alpha_in" Unit="m/s" Routing="" UnityObject="CraneBoomCrash" UnityName="collider1" NetworkConvert="1"></Signal>
<Signal Type="float" Name="theta_in" Unit="m/s" Routing="" UnityObject="CraneBoomCrash" UnityName="collider1" NetworkConvert="1"></Signal>
<Signal Type="float" Name="phi_in" Unit="m/s" Routing="" UnityObject="CraneBoomCrash" UnityName="collider1" NetworkConvert="1"></Signal>
</Packet>
</IOConfig>
必要な出力は、Out、Out1、collider1です。
つまり、UnityNameの重複する値は出力されません。これはできますか?
UnityNameの重複する値を読み取るコードを切り取った:
public class XMLStringReader : MonoBehaviour
{
public string slectedItem;
private bool editing = false;
public string signalsa;
public XmlReaderSettings settings;
void OnGUI ()
{
if ( GUILayout.Button(slectedItem))
{
editing = true;
}
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
settings.IgnoreComments = true;
using ( XmlReader reader = XmlReader.Create("D://Docs/Unity3D/cdp/UDPApplication/Components/UDPIOServer.xml", settings) )
{
while ( reader.Read() )
{
if ( reader.NodeType == XmlNodeType.Element )
{
if ( reader.HasAttributes )
{
if ( reader.GetAttribute("UnityName") != null )
{
signalsa = reader.GetAttribute("UnityName");
string [] signalsCDP = {signalsa};
if (editing)
{
for(int i =0; i < signalsCDP.Length; i++)
{
if (GUILayout.Button(signalsCDP[i]))
{
slectedItem = signalsCDP[i];
editing = false;
print(signalsCDP[i].ToString());
}
}
}
}
}
}
}
}
}
}