using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
namespace S3
{
public class Health : NetworkBehaviour {
public const int maxHealth = 100;
[SyncVar (hook = "OnChangeHealth")]public int currentHealth = maxHealth;
public RectTransform healthbar;
public void TakeDamage(int amount)
{
if (!isServer)
{
return;
}
currentHealth -= amount;
if (currentHealth <= 0)
{
currentHealth = maxHealth;
RpcRespawn();
}
}
void OnChangeHealth(int health)
{
healthbar.sizeDelta = new Vector2(health * 2, healthbar.sizeDelta.y);
}
[ClientRpc]
void RpcRespawn()
{
if(isLocalPlayer)
{
transform.position = Vector3.zero;
}
}
}
}
如何从MachineEntrys中将uuid和src从此xml中获取到数组? .net 4.5
我试过了,因为数组是空的:
**请勿编辑此文件。 **如果您在任何VirtualBox相关应用程序中对此文件进行更改 **正在运行,您的更改将在稍后被覆盖,而不会生效。 **使用VBoxManage或VirtualBox Manager GUI进行更改。
<?xml version="1.0"?>
<!--
** DO NOT EDIT THIS FILE.
** If you make changes to this file while any VirtualBox related application
** is running, your changes will be overwritten later, without taking effect.
** Use VBoxManage or the VirtualBox Manager GUI to make changes.
-->
<VirtualBox xmlns="http://www.virtualbox.org/" version="1.12-windows">
<Global>
<ExtraData>
<ExtraDataItem name="GUI/GroupDefinitions/" value="m=254e0435-0f3f-445b-a35d-1f6d774a0fc3"/>
<ExtraDataItem name="GUI/LastItemSelected" value="m=from_diag"/>
<ExtraDataItem name="GUI/LastWindowPosition" value="255,217,770,550"/>
<ExtraDataItem name="GUI/RecentFolderHD" value="//diag03-pc/vbox_hdd"/>
<ExtraDataItem name="GUI/RecentListHD" value="\\diag03-pc\vbox_hdd\xp_legacy_mode.vdi"/>
<ExtraDataItem name="GUI/SplitterSizes" value="255,510"/>
<ExtraDataItem name="GUI/Toolbar/MachineTools/Order" value="None"/>
<ExtraDataItem name="GUI/UpdateCheckCount" value="3"/>
<ExtraDataItem name="GUI/UpdateDate" value="1 d, 2017-10-23, stable, 5.2.0"/>
</ExtraData>
<MachineRegistry>
<MachineEntry uuid="{254e0435-0f3f-445b-a35d-1f6d774a0fc3}" src="C:\Users\bogna\VirtualBox VMs\from_diag\from_diag.vbox"/>
</MachineRegistry>
<NetserviceRegistry>
<DHCPServers>
<DHCPServer networkName="HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter" IPAddress="192.168.56.100" networkMask="255.255.255.0" lowerIP="192.168.56.101" upperIP="192.168.56.254" enabled="1"/>
</DHCPServers>
</NetserviceRegistry>
<SystemProperties defaultMachineFolder="C:\Users\bogna\VirtualBox VMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/>
<USBDeviceFilters/>
</Global>
</VirtualBox>
答案 0 :(得分:0)
您忽略了XML命名空间。你可以试试:
XmlNodeList nodes = doc.DocumentElement.SelectNodes("//*[local-name()='MachineEntry']");
(如果需要,使用local-name()函数展开其他级别)