How to create a

Hey guys, i’m struggling a little bit with creating new instances
my problem is pretty simple, in my code im importing an instance of an object,
this object inherits from AbilityEffect, however the object itself is a seperate
class that inherits from AbilityEffect(Just reiterating), what i want to do is
create a new instance of the imported object of the same class, I want to beable
to pass information into the constructor… I pretty much just want to beable to choose
type based on imported type!

public class EffectHandler : MonoBehaviour {
	
	private AbilityEffect abilityEffect;

    //let inAbilityEffect be effect1 which inherits AbilityEffect for example.
	public void performEffect(AbilityEffect inAbilityEffect) 
	{
		abilityEffect = new (inAbilityEffect.getType())(//Classconstructor);
		abilityEffect.performBehaviour();
	}
}

Hopefully this isn’t too vague, i found this hard to put into words hence why i couldn’t find this in the search bar.

Thanks for your time,
Bazzalisk.

How about…

Type t = Type.GetType(inAbilityEffect);

Object abilityEffect = Activator.CreateInstance(t);

Then invoke the members as required.