How to call a new instance of a class in C#

Hi,

This seems like a basic question but the answers I’m finding on google are convoluted. There’s got to be a simple way to say:

public void FadeLOSInfo()
{
	renderer = GetComponent();
	Material[] originalMaterials;
	Material[] alphaMaterials;
	var needFadeOut = true;
}

FadeLOSInfo fadeInfo = new FadeLOSInfo();

1 Answer

1

Constructor?

public class FadeLOSInfo() {
  public /*nothing goes here*/ FadeLOSInfo() {
    // initialize
  }
}

fadeInfo = new FadeLOSInfo();

Ah whoops, I was translating a script and didn't notice it was meant to be a class. How embarassing! Thanks.