Search Unity

Creating a Custom Editor Script to create a list of objects which Inherit from a base class

Discussion in 'Editor & General Support' started by Frankie3, Jun 17, 2021.

  1. Frankie3

    Frankie3

    Joined:
    Jan 29, 2014
    Posts:
    13
    I have a class that iterates over a list of events and updates each one. When all of the events are finished updating the class destroys itself. I’m trying to find some resources for building a custom inspector script to display a list of events and then in another script load then into my class during runtime. The events all implement an interface and have different properties depending on the event and I’d like to be able to select the event type when adding to the list.
    An example of my events would be like this
    public class SimpleEvent : IEvent{
    void Run()
    }
    public class ComplexEvent : IEvent{
    public string s;
    public int i;
    void Run()
    }

    public class EventRunner{
    void Update(){
    while(eventsNotFinished){
    foreach(event) event.Run()
    }}

    The list in the inspector would select a Data version of the event with just the properties and then during runtime would read the data and create the event I need.