Is it possible to use enum value to reference a variable in scriptable object?
Hi, im not sure if this has asked before, but couldnt find anywhere else.
I have ScriptableObject to store the preset values:
public class ColorCode : ScriptableObject {
private Color idle= Color.gray;
public Color available = Color.green;
}
Currently using switch statement to assign the variable.
public class SetColors : MonoBehaviour {
public enum State{idle, available}
public State itemState = State.idle;
public ColorCode colorCode;
void Start(){
//currently using get method with switch statement
item.setColor("_ColorCode", getColor(itemState));
}
}
Ideally, i want to use the enum value directly to reference the value without switch statement like so.
item.setColor("_ColorCode", itemState);
Another option I found is using multiple SO in the list and map through. But I dont want to have alot of SO just to keep the color code.
Essentially, I think this is similar to converting string into variable name. But since its an enum value, so is it possible to use the value directly, without having to use Switch statement to check?
Thank you.
Your answer
Follow this Question
Related Questions
Extendable Enums with ScriptableObjects 2 Answers
Does loading a ScriptableObject on runtime and modifying it affect the ScriptableObject in file? 1 Answer
Scripting Movement Fails for Instantiated Prefab 2 Answers
Items/Inventory system using Scriptable Objects and Composition instead Inheritance. 0 Answers
What is the benefit of creating a scriptable object? 2 Answers