I have the following typescript enum:
export enum Textures {
earth = "Earth",
colors = "Colors",
disturb = "Disturb",
...,
many = "More"
}
Further I have a GUI where i set my initial texture to show:
export class DefaultSettings {
texture: Textures = Textures.earth;
//more Settings
}
let settings = new DefaultSettings();
So when i change the value in my GUI, selecting "Colors" I don't want to write my callback for every single entry in the enum. eg:
if(selcted.value == "Colors"){
settings.texture = Textures.colors;
}
if(selcted.value == "Disturb"){
settings.texture = Textures.disturb;
}
if(selcted.value == "Earth"){
settings.texture = Textures.earth;
}
...
if(selcted.value == "More"){
settings.texture = Textures.many;
}
How can I set the Texture Enum object into the settings.texture attribute? E.G.:
settings.texture = Textures.X // This saves the string, but I want the object itself
or
settings.texture = Textures[X] // wrong since it puts 'string' instead of 'Textures'
Thank you for any help!