Exemplo n.º 1
0
        void Start()
        {
            // A helper extension is provided to check for flags
            if (Animal.HasFlag(AnimalType.Cat))
            {
                Debug.Log("Cat flag is set");
            }

            if (Animal.HasFlag(AnimalType.Cat | AnimalType.Fish))
            {
                Debug.Log("Cat & Fish flags are set");
            }
        }
 public void InstantiateAnimal(AnimalType type)
 {
     if (type.HasFlag(AnimalType.Bee))
     {
         Instantiate(BeePrefab, BoxRootTransform, false);
     }
     if (type.HasFlag(AnimalType.Mouse))
     {
         Instantiate(MousePrefab, BoxRootTransform, false);
     }
     if (type.HasFlag(AnimalType.Spider))
     {
         Instantiate(SpiderPrefab, BoxRootTransform, false);
     }
 }
 private static IEnumerable <string> GetAnimalNames(AnimalType animals)
 {
     if (animals.HasFlag(AnimalType.Bee))
     {
         yield return("Bee");
     }
     if (animals.HasFlag(AnimalType.Mouse))
     {
         yield return("Mouse");
     }
     if (animals.HasFlag(AnimalType.Spider))
     {
         yield return("Spider");
     }
 }