You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.2 KiB
48 lines
1.2 KiB
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<ReportErroeSyncData> events = new List<ReportErroeSyncData>(); |
|
// 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<EventItem>().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 () { |
|
|
|
} |
|
}
|
|
|