setting enum to another enum/ casting enum “closed”

Updated on October 9, 2017 in [A] Unity Scripting
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
2 on October 9, 2017

hi, I am trying to set an enum to a list gameobjects enum. cant figure out how to cast the enum right. This is the error CS0266: Cannot implicitly convert type ItemTpye’ to ItemTpeys’. An explicit conversion exists (are you missing a cast?) 




      public GameObject itemHolderPrefab;
      public Transform grid;
      public static Shop shop;
      public List itemList = new List();
      private List itemHolderList = new List();
      public List buyButtonList = new List();
     public int currentWeaponID = 1;
     public GameObject noGoldImage;
     public bool noGoldActive = false;
     public GameController controller;
     private void Awake()
               shop = this;
     void Start () {
         controller = GameController.controller;
         if(controller.hasItem == true)
                 itemList = controller.shopList;
    void FillList()
         for (int i = 0; i < itemList.Count; i++)
         GameObject holder = Instantiate(itemHolderPrefab, grid, false);
         ItemHolder holderScript = holder.GetComponent();
         holderScript.itemName.text = itemList[i].itemName;
         holderScript.itemPrice.text = "Gold " + itemList[i].itemPrice.ToString();
         holderScript.itemId = itemList[i].mainID;
         holderScript.itemImage.sprite = Resources.Load("Sprites/" + itemList[i].spriteName);
         //here is were the error is
         holderScript.itemTpeys = (ItemTpye)itemList[i].itemtpye;
         holderScript.buyButten.GetComponent().itemID = itemList[i].mainID;
  • Liked by
1 on October 9, 2017

i have fix it on line 35  holderScript.itemTpeys = (ItemTpeys)itemList[i].itemtpye;

on October 9, 2017

So you don’t need help anymore and this one can be closed?


Show more replies
  • Liked by