Good morning. I have a function that reads data from an xml that is this:
private string xmlPath;
public XmlManager(string xmlPath) {
this.xmlPath = xmlPath;
}
public Datos ReadXmlTest() {
XmlSerializer serializer = new XmlSerializer(typeof(Datos));
StreamReader reader = new StreamReader(xmlPath);
Datos data = (Datos)serializer.Deserialize(reader);
reader.Close();
return data;
}
What I do with that is to get some routes of some photos and save all the routes in data.
Then I have this class
using System.Diagnostics;
using UnityEngine;
public class AppButton : MonoBehaviour {
private Juego game;
public void Init(Juego game) {
this.game = game;
}
private void RunApp() {
Process.Start(game.ruta);
}
}
and then I have this class where the foreach is
private Datos data;
public GameObject Button;
void Awake() {
string path = "C:/Users/datos.xml";
XmlManager xmlMng = new XmlManager(path);
data = xmlMng.ReadXmlTest();
foreach (var juego in data.Juegos) {
GameObject newButton = (GameObject)Instantiate(Button);
newButton.GetComponent<AppButton>();
//
//
}
}
In the last class where they are // I have to Call the AppButton Init with a game but I do not know how to do it. And apart from that, how can I make a button with the image that exists in the xml routes for each element that goes on in the xml?