Twice as many classes created than called

I created an event system, with two classes, a event class and a class that keeps track of all the event classes by using a list (HashSet, to be precise). the add function is called in the constructor of the event class.

the problem is that there are twice as many classes in the list than expected. I logged the add function and this is what is saw.

The class I create the event classes:

public class ___testScript : MonoBehaviour
{
    public h_Event m_event = new h_Event("Testing");
    public h_Event m_event2 = new h_Event("Testing2");
}

50778-untitled.png

notice the two messages before and the two after I pressed stop, it does not say where i called it.

and notice the first two, they don’t have a name.

(First)
Register:
UnityEngine.Debug:Log(Object)
h_Event:Register() (at Assets/Scripts/Gameplay/Framework/Event/h_Event.cs:327)
h_Event:Initialize() (at Assets/Scripts/Gameplay/Framework/Event/h_Event.cs:162)
h_Event:.ctor() (at Assets/Scripts/Gameplay/Framework/Event/h_Event.cs:46)

(Third)
Register: Testing
UnityEngine.Debug:Log(Object)
h_Event:Register() (at Assets/Scripts/Gameplay/Framework/Event/h_Event.cs:327)
h_Event:Initialize() (at Assets/Scripts/Gameplay/Framework/Event/h_Event.cs:162)
h_Event:.ctor(String, CallTime, Single, Single) (at Assets/Scripts/Gameplay/Framework/Event/h_Event.cs:57)
___testScript:.ctor()

So where are the first 2 and the last 4 called?

Edit: I deleted the h_Event() constructor (the empty one) and now the first two logs are not called, but there are still twice as many classes created. and where would the would they be called?

You instantiate a component not in the traditional C# way. But rather by writing

public h_Event m_event;

then instantiate it in the start, awake or where you want to activate it by:

m_event = GetComponent();