Unity3D で C# を使用して XML ノードを追加および削除する必要があります。XML ファイルにはPurchased-Assets
とがありUnbought-Assets
ます。UnPurchased-Asset
ボタンをクリックすると、ノードから名前付きを削除し、このアイテムをとしてUnbought-Assets
追加したいと考えています。どこから始めればよいかわかりません。Purchased-Assets
Purchased-Asset
これまでのコード (C#):
using UnityEngine;
using System.Collections;
using System.Xml;
using System.IO;
public class MyAppStuffCode : MonoBehaviour
{
XmlDocument xml;
public XmlNodeList _name;
//Used to load XML file.
xml = new XmlDocument();
xml.Load(Application.dataPath + "/Resources/MyAppStuffXml.xml");
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
public void OnButtonClicked(string BName)
{
// Code to add/remove XML nodes here!
}
}
XML ファイルの例:
<TreasureChart>
<Dudes>
<Rapper>
<!-- Purchased assets -->
<Purchased-Assets>
<Purchased-Asset>
<Name>BackTalk</Name>
<ID>A</ID>
<Points>20</Points>
</Purchased-Asset>
<Purchased-Asset>
<Name>Beard</Name>
<ID>B</ID>
<Points>20</Points>
</Purchased-Asset>
<Purchased-Asset>
<Name>IntroRap</Name>
<ID>C</ID>
<Points>20</Points>
</Purchased-Asset>
<Purchased-Asset>
<Name>Moustache</Name>
<ID>D</ID>
<Points>20</Points>
</Purchased-Asset>
<Purchased-Asset>
<Name>MyFaceDudeRap</Name>
<ID>E</ID>
<Points>20</Points>
</Purchased-Asset>
<Purchased-Asset>
<Name>MyFaceMyRap</Name>
<ID>F</ID>
<Points>20</Points>
</Purchased-Asset>
</Purchased-Assets>
<!-- Unbought assets -->
<Unbought-Assets>
<UnPurchased-Asset>
<Name>Share</Name>
<ID>D</ID>
<Points>20</Points>
</UnPurchased-Asset>
<UnPurchased-Asset>
<Name>SunGlasses</Name>
<ID>E</ID>
<Points>20</Points>
</UnPurchased-Asset>
</Unbought-Assets>
</Rapper>
</Dudes>
</TreasureChart>