I am creating an Editor Window, and in the editor window code I have this method:
void AddEvent<T>(){
var evt = ScriptableObject.CreateInstance(typeof(T)) as EventObject;
bool added = eventSystem.AddEvent(evt);
}
When AddEvent is called with an object that is selected in the hierarchy, it adds the class to the eventObjects list just fine. However, when a prefab is selected in the projects tab, it adds it but it says Type Mismatch.
private List<EventItem> eventObjects = new List<EventItem>();
[System.Serializable()]
public class EventItem{
public EventObject evt;
public EventItem(EventObject item){
evt = item;
}
}
public bool AddEvent(EventObject eventObject){
eventObjects.Add(new EventItem(eventObject));
}