Hello this is my class
//Factory
public class ColorFactory
{
private static Dictionary<Colors, Func<ColorMatch>> colormap = new Dictionary<Colors, Func<ColorMatch>> ()
{
{Colors.BlueMaterial, () => {return new BlueMaterial(); }},
{Colors.OrangeMaterial, () => {return new OrangeMaterial(); }},
{Colors.PurpleMaterial, () => {return new PurpleMaterial(); }},
{Colors.RedMaterial, () => {return new RedMaterial(); }},
{Colors.YellowMaterial, () => {return new YellowMaterial(); }},
{Colors.GreenMaterial, () => {return new GreenMaterial(); }}
};
public static ColorMatch CreateColorFromName (string name)
{
Colors getType = (Colors)Enum.Parse (typeof(Colors), name);
return colormap[getType]();
}
}
How to fix this problem, I don’t really understand.
I know that this is c# way to make a new thing, but how to do it in Unity ?
I found that something with g
gameObject.AddComponent<BlueMaterial>()
But this is not working.
I need help )