So I seem to be unable to use it… when I try to apply it in the Start function it does not seem to recognize “RequiredSupport” as an enum. It doesn’t autocomplete it. How come?
using UnityEngine;
using System.Collections;
public class ModelProperties : MonoBehaviour {
public enum RequiredSupport (Yes, No);
// Use this for initialization
void Start () {
RequiredSupport = Yes;
}
// Update is called once per frame
void Update () {
}
}
You need to use curly braces instead of normal ones:
public enum RequiredSupport
{
Yes,
No
}
Just out of curiosity though, if the only options are yes or no, why not use a boolean?
1 Like
Because I wanted to see how to use enumerations correctly for the future.
Thanks for the help!
-
use curly braces
-
that will only declare the enumeration type, you haven’t created a variable to store the enum.
using UnityEngine;
using System.Collections;
public class ModelProperties : MonoBehaviour {
public enum SupportRequirement
{
Yes,
No
}
public SupportRequirement RequiresSupport;
// Use this for initialization
void Start () {
RequiresSupport = SupportRequirement.Yes;
}
// Update is called once per frame
void Update () {
}
}