- Home /
Enum not working properly.
I have the following function:
private void CamModes()
{
if (GUIHandler.UseCamera)
{
mode = PPCam.EnumCamModes.MouselookActive;
}
else if (Input.GetMouseButtonDown(1))
{
Debug.Log("RMB");
mode = PPCam.EnumCamModes.MouselookNotActiveRMB;
}
else if (Input.GetMouseButtonDown(2))
{
Debug.Log("MMB");
mode = PPCam.EnumCamModes.MouselookNotActiveMMB;
}
else
{
mode = PPCam.EnumCamModes.MouselookNotActive;
}
}
The first and the last one work, but the second and third only execute the Debug.Log()
-bit.. Any idea what might have gone wrong? Mono debugger crashes my Unity, so can't see what's actually happening...
If the first and last sets work, then assu$$anonymous$$g that your enum structure contains what you have listed there, then there's no reason why setting the enum-type variable to those values shouldn't work. How do you know that the value isn't being changed?
I have it displayed in the editor when testing the game, that's how I know it.
Answer by Skjalg · Jul 10, 2011 at 08:10 PM
You probably want to use Input.GetMouseButton instead of Input.GetMouseButtonDown since the Down version only works for one frame.
Will have to try that tomorrow, got to go now. But I'll keep you updated, thanks ;)
Your answer

Follow this Question
Related Questions
Flag structure variable in unity editor 1 Answer
How to set a value for each level without using a switch statement 2 Answers
Enums are not staying set between Editor and MonoBehavior (target) class 1 Answer
String to enum 2 Answers
What is the best way to pick random value form enum in other class? 1 Answer