Question about components in a list

Hey guys, I am trying to create a tool for my level designer that would allow him to dynamically spawn managers for his scenes.

    [SerializeField] List<Object> lManagersThatSpawnAtStart = new List<Object>();
    //..
        foreach(Object component in lManagersThatSpawnAtStart)
        {
            GameObject newComponent = new GameObject();
            newComponent.name = component.name.ToString();

            //How the hell can I attach "component" to it?!

        }

Basically I want

newComponent.AddComponent<component>();

It’s lost on me how I can attach it from the list to the empty game object, Can you please help me :slight_smile:

Use the Activator class:

System.Activator.CreateInstance(Type.GetType("ComponentType"));

Remember the use the full qualified name of your ComponentType.

Here’s the Activator class reference

Regards