- Home /
access enum value ( in csharp but not mandatory)
Hi,
I would like to access the actual value of the enum I declared. I fear this is against good practice, but I'll ask anyway :) The example below is in cSharp, but I would be glad to hear solutions for other languages as well.
public enum mouseLookTrigger { AlwaysOn = -1, LeftMouse = 0, MiddleMouse = 2, RightMouse = 1 }
public mouseLookTrigger trigger = mouseLookTrigger.LeftMouse;
basically, it start to make sense here because I could directly inject the actual value in
Input.GetMouseButton(trigger);
but that doesn't work, I get
error CS1503: Argument 1: Cannot convert type
MouseLook.mouseLookTrigger' to
int'
So, How can I access the value 0
if trigger
is equal to mouseLookTrigger.LeftMouse
? else, what would be the preferred way to get around such problem and script good practices?
Thanks,
Jean
Your answer
![](https://koobas.hobune.stream/wayback/20220613071941im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
using enum value in cs? 1 Answer
Access objects enum type 1 Answer
Alternative way of accessing other scripts? 2 Answers
Inconsistent Accessibility: Parameter type is less accessible than method 1 Answer
Using Enum across several files 3 Answers