List keeps losing items.
Basically I'm attempting to create an event handler that will add events to a list and call the characters EventProc() when an event happens. My event handler seems to work correctly. The issue is when I'm attempting to handle the event in EventProc() my characterEvents is showing the correct size, however, all the indexes are showing as "None (Event)". This causes all events to proc any time one of them is suppose to.
What I need is for my characterEvents list to maintain the data I add to it, so that I can correctly compare the difference between events.
I made a small sample of a character, which has the same issue when I add it to my program, so it will be less code to dredge through to try and isolate the problem. But I still cant seem to solve it.
public class Character : MonoBehaviour
{
public List<Event> characterEvents;
Event event1;
Event event2;
void Start()
{
characterEvents = new List<Event>();
AddCharacterEvents();
EventHandler.InsertEvent(characterEvents[0]);
}
public void EventProc(Event procEvent)
{
if (procEvent == characterEvents[0])
{
Debug.Log("Event 1 Happened");
EventHandler.InsertEvent(characterEvents[1]);
}
if (procEvent == characterEvents[1])
{
Debug.Log("Event 2 Happened");
}
}
void AddCharacterEvents()
{
event1 = new Event(1.0f, 0.0f, this);
event2 = new Event(10.0f, 0.0f, this);
characterEvents.Add(event1);
characterEvents.Add(event2);
}
}
So, I've tried a few more things to try and solve this. But still no luck. I noticed unity shows 408 people following this question, but no response makes me there is either not a good reason for it to be doing this, or its something so basic I'm overlooking that no one wanted to call me out on it.
In either case I appreciate you all at least looking at and following it.
Thank you.
Your answer
Follow this Question
Related Questions
Using a specific function from a generic object. 0 Answers
Most efficient way to store information in an inspector dropdown menu? 0 Answers
How to add a Type to a Class in Javascript? 1 Answer
Array (List) with multiple variable types? 2 Answers
How To Find GameObject From List And Add To Player List 0 Answers