using AX.MessageSystem; using System.Collections; using System.Collections.Generic; using UnityEngine; public class EventsManager : MonoBehaviour { private static EventsManager instance; public static EventsManager Instance { get { return instance; } } void Awake() { instance = this; } public GameObject itemPre; public Transform content; public GameObject panel; public List events = new List(); // Use this for initialization void Start () { if (itemPre == null) { itemPre = Resources.Load("EventItem") as GameObject; } MessageDispatcher.AddListener("ReportError", addNewEvent); } public void CreateEventItem(ReportErroeSyncData info) { GameObject item = Instantiate(itemPre, content); item.name = "EventItem-" + item.transform.GetSiblingIndex(); item.GetComponent().Set(info); } public void addNewEvent(IMessage obj) { var info = (ReportErroeSyncData)obj.Data; events.Add(info); CreateEventItem(info); } // Update is called once per frame void Update () { } }