void Generatexml (dictionary<string, prefabdict> dict)
{
String Xmlpath = Application.datapath + "/editor/characterseffectpoint/effectpointsinfo.xml";
if (file.exists (Xmlpath))
{
Debug.Log (Xmlpath);
File.delete (Xmlpath);
}
XmlDocument xmldoc = new XmlDocument ();
XmlDeclaration xmldecl;
Xmldecl = Xmldoc.createxmldeclaration ("1.0", "UTF-8", null);
XmlElement root = xmldoc.documentelement;
Xmldoc.insertbefore (xmldecl, Root);
XmlElement infoBase = xmldoc.createelement ("InfoBase"); Create root node, top-level node role name
Xmldoc.appendchild (infoBase);
foreach (var dic in Dict)
{
XmlElement characterinfo = xmldoc.createelement ("Effectpointsinfo");
Infobase.appendchild (Characterinfo);
XmlElement Characterkey = xmldoc.createelement ("Character");
XmlElement head_c_effectpoint = xmldoc.createelement ("Head_c_effectpoint");
XmlElement head_t_effectpoint = xmldoc.createelement ("Head_t_effectpoint");
XmlElement hand_l_effectpoint = xmldoc.createelement ("Hand_l_effectpoint");
XmlElement hand_r_effectpoint = xmldoc.createelement ("Hand_r_effectpoint");
XmlElement foot_l_effectpoint = xmldoc.createelement ("Foot_l_effectpoint");
XmlElement foot_r_effectpoint = xmldoc.createelement ("Foot_r_effectpoint");
XmlElement chest_effectpoint = xmldoc.createelement ("Chest_effectpoint");
XmlElement bottom_effectpoint = xmldoc.createelement ("Bottom_effectpoint");
XmlElement weapon01_effectpoint = xmldoc.createelement ("Weapon01_effectpoint");
XmlElement normal_hurtpoint = xmldoc.createelement ("Normal_hurtpoint");
XmlElement special_hurtpoint = xmldoc.createelement ("Special_hurtpoint");
XmlElement footsteps_effectpoint = xmldoc.createelement ("Footsteps_effectpoint");
Characterkey.innertext = dic. Key.tostring ();
Head_c_effectpoint.innertext = dic. Value.Head_C_EffectPoint.ToString ();
Head_t_effectpoint.innertext = dic. Value.Head_T_EffectPoint.ToString ();
Hand_l_effectpoint.innertext = dic. Value.Hand_L_EffectPoint.ToString ();
Hand_r_effectpoint.innertext = dic. Value.Hand_R_EffectPoint.ToString ();
Foot_l_effectpoint.innertext = dic. Value.Foot_L_EffectPoint.ToString ();
Foot_r_effectpoint.innertext = dic. Value.Foot_R_EffectPoint.ToString ();
Chest_effectpoint.innertext = dic. Value.Chest_EffectPoint.ToString ();
Bottom_effectpoint.innertext = dic. Value.Bottom_EffectPoint.ToString ();
Weapon01_effectpoint.innertext = dic. Value.Weapon01_EffectPoint.ToString ();
Normal_hurtpoint.innertext = dic. Value.Normal_HurtPoint.ToString ();
Special_hurtpoint.innertext = dic. Value.Special_HurtPoint.ToString ();
Footsteps_effectpoint.innertext = dic. Value.Footsteps_EffectPoint.ToString ();
Characterinfo.appendchild (Characterkey);
Characterinfo.appendchild (Head_c_effectpoint);
Characterinfo.appendchild (Head_t_effectpoint);
Characterinfo.appendchild (Hand_l_effectpoint);
Characterinfo.appendchild (Hand_r_effectpoint);
Characterinfo.appendchild (Foot_l_effectpoint);
Characterinfo.appendchild (Foot_r_effectpoint);
Characterinfo.appendchild (Chest_effectpoint);
Characterinfo.appendchild (Bottom_effectpoint);
Characterinfo.appendchild (Weapon01_effectpoint);
Characterinfo.appendchild (Normal_hurtpoint);
Characterinfo.appendchild (Special_hurtpoint);
Characterinfo.appendchild (Footsteps_effectpoint);
}
Xmldoc.save (Xmlpath); Create a Effectpointsinfo.xml file
Assetdatabase.refresh ();
This. Shownotification (New Guicontent ("Data generation:" + Xmlpath));
}
Data generation XML Import into Excel