Enum dropdown affecting anther Enum dropdown?
I'm working on a card game demo and I'm trying to use inspector dropdowns to easily find and set a card to a specific type of card. I am wondering if I can use my "whatCardTypeIsThis" Enum dropdown to affect a second Enum dropdown. For example, I want to have the Combat Cards show in the second dropdown is the first dropdown is equal to cardType.Card_TypeCombat, and the same for the other dropdown selections. Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
public class Card : MonoBehaviour
{
[Header("Card Text UI Elements")]
public Text cardNameText, DamageText, cardCostText;
[Header("Card Name")]
public string cardName;
[Header("Card Int Values")]
public int Damage, cardCost;
[Header("Card Type")]
public cardType whatCardTypeIsThis;
// EnumDropDown
private void Start()
{
if (whatCardTypeIsThis.Equals(cardType.Card_Type_Combat))
{
}
else if(whatCardTypeIsThis.Equals(cardType.Card_Type_Dark))
{
}
else if (whatCardTypeIsThis.Equals(cardType.Card_Type_Fire))
{
}
else if (whatCardTypeIsThis.Equals(cardType.Card_Type_Magic))
{
}
else if (whatCardTypeIsThis.Equals(cardType.Card_Type_Nature))
{
}
else if (whatCardTypeIsThis.Equals(cardType.Card_Type_Stealth))
{
}
else if (whatCardTypeIsThis.Equals(cardType.Card_Type_Water))
{
}
}
//CARDS
//CARD TYPES
public enum cardType
{
Card_Type_Combat,
Card_Type_Magic,
Card_Type_Fire,
Card_Type_Stealth,
Card_Type_Water,
Card_Type_Nature,
Card_Type_Dark
}
public enum combatCards
{
Card_Punch_001,
Card_SonicJab_002,
Card_ColossalCrush_003
}
public enum magicCards
{
Card_FireBall_004,
Card_LightningStrike_005,
Card_MagicMissle_006
}
public enum fireCards
{
Card_Burn_007,
Card_Erupt_008,
Card_Supernova_009
}
public enum stealthCards
{
Card_SneakStrike_010,
Card_Vanish_011,
Card_SlightOfHand_012
}
public enum waterCards
{
Card_Drench_013,
Card_Torrent_014,
Card_Typhoon_015
}
public enum natureCards
{
Card_Entangle_016,
Card_OverGrow_017,
Card_NaturesBounty_18
}
public enum darkCards
{
Card_Enshroud_019,
Card_Transformation_020,
Card_ShadowClone_021
}
}
Answer by streeetwalker · Sep 10, 2020 at 12:04 PM
@Xrank, on its face it won't work, and there is no easy way to get it to work. Ultimately Enum values can be represented as integers. They cannot be used directly as pointers to other Enums.
So one way to do what you want is to keep your 2nd level card Enum groups in an array or list, and use the integral representation of your first level Enum to index the array for each card group and populate your 2nd level menu.
Your answer
![](https://koobas.hobune.stream/wayback/20220613011555im_/https://answers.unity.com/themes/thub/images/avi.jpg)