title: How can I make a switch statement work with an enum? C# Unity
body: <p><strong>Description</strong></p>
  
  <p>I'm working on a script to fade UI elements in Unity, similar to a selector, where you can select the type of fading, and duration, and image to fade</p>
  
  <p><a href="https://i.stack.imgur.com/fPThW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fPThW.png" alt="enter image description here"></a></p>
  
  <p>I found that enum is the best option to achieve that result, but I have a problem, when I run the code only element of the enum work and the other don't, no matter if I use <code>switch</code>or <code>if</code> just the first statement run, I don't know what's wrong with the code</p>
  
  <ul>
  <li>Please explain your answer</li>
  <li>Please explain why the code is wrong</li>
  <li>Please give feedback on how to improve</li>
  </ul>
  
  <p>I'm using Unity version 5.3.5f1 and Visual Studio Community 2015</p>
  
  <p><strong>Goal</strong></p>
  
  <ul>
  <li>Make the enum work properly using either <code>switch</code> or <code>if</code></li>
  <li>Be able to use the variables inside the FadeOperations class to make
  the calculations inside the Test class</li>
  <li>Select from an array the type of desired operation</li>
  <li>Select an UI element from Heriarchy and fade it</li>
  </ul>
  
  <p><strong>Steps</strong></p>
  
  <ul>
  <li>Create new Unity project (2D or 3D)</li>
  <li>Create UI Image</li>
  <li>Create Empty game object</li>
  <li>Create new C# script (I called it Test)</li>
  <li>Attach new script to empty game object</li>
  </ul>
  
  <p><strong>Code</strong></p>
  
  <p>Here's my code...</p>
  
  <pre><code>using UnityEngine;
  using UnityEngine.UI;
  
   public enum FadeManager
   {
       fadeIn,
       fadeOut
   };
  
   [System.Serializable]
   public class FadeOperations
   {
       [Tooltip("Type of fading")]
       public FadeManager fadeType;
  
       [Tooltip("Duration time of the fading")]
       public float duration;
  
       [Tooltip("Select the image to fade")]
       public Image fadeImage;
   }
  
   public class Test : MonoBehaviour
   {
       [Tooltip("Select your type of fade")]
       public FadeOperations[] fadeOperations;
  
       //Reference to the class FadeOperations
       private FadeOperations _fo = new FadeOperations();
  
       //Loop for debug
       private void Start()
       {
           Debug.Log(_fo.fadeType);
           switch (_fo.fadeType)
           {
               //This statement works
               case FadeManager.fadeIn:
                   Debug.Log("Fadein"); //Only this piece of code works
                   break;
  
               //This statement doesn't work
               case FadeManager.fadeOut:
                   Debug.Log("Fadeout");
                   break;
           }
        }
    }
  </code></pre>
  
  <p>The result of the Log <code>(_fo.fadeType)</code> before the <code>switch</code></p>
  
  <pre><code>fadeIn
  UnityEngine.Debug:Log(Object)
  Test:Start() (at Assets/_Scripts/Test.cs:34)
  </code></pre>