UpdateSlot()

Found in:

public void UpdateSlot(){
    if(itemAmount == 0){
      gameObject.transform.Find("bg").gameObject.SetActive(true);
      gameObject.transform.Find("bgEmpty").gameObject.SetActive(true);
      gameObject.transform.Find("Text").GetComponent().text = "";
      if(gameObject.transform.Find("numberbg")){
        gameObject.transform.Find("numberbg").GetComponent().text = "";
      }
      if(gameObject.transform.Find("textbg")){
        gameObject.transform.Find("textbg").GetComponent().color = new Color32(255,255,225,0);
        gameObject.transform.Find("textbg").GetComponent().material = null;
      }
      if(gameObject.transform.Find("TextShadow")){
        gameObject.transform.Find("TextShadow").GetComponent().text = "";
      }
      fullItem = null;
      itemName = "";
    }else{
      gameObject.transform.Find("bg").gameObject.SetActive(true);
      gameObject.transform.Find("bgEmpty").gameObject.SetActive(false);
      gameObject.transform.Find("Text").GetComponent().text = itemAmount.ToString();
      if(gameObject.transform.Find("numberbg")){
        gameObject.transform.Find("numberbg").GetComponent().text = itemAmount.ToString();
      }

      if(gameObject.transform.Find("TextShadow")){
        gameObject.transform.Find("TextShadow").GetComponent().text = itemAmount.ToString();
      }
    }

    if(iconType == null){
      gameObject.transform.Find("Image").GetComponent().sprite = null;
      gameObject.transform.Find("Image").GetComponent().color = new Color32(255,255,225,5);
      if(gameObject.transform.Find("textbg")){
        gameObject.transform.Find("textbg").GetComponent().color = new Color32(255,255,225,0);
        gameObject.transform.Find("textbg").GetComponent().material = null;
      }
      fullItem = null;
      itemName = "";
    }else{
      showIcon = iconType;
      itemName = fullItem.GetName();
      float canvasSize = fullItem.GetCanvasSize();

      if(showIcon.bounds.extents.y > showIcon.bounds.extents.x){
        ratio = showIcon.bounds.extents.y/showIcon.bounds.extents.x;
        gameObject.transform.Find("Image").GetComponent().transform.localScale = new Vector3(canvasSize / ratio, canvasSize, canvasSize);
      }else{
        ratio = showIcon.bounds.extents.x/showIcon.bounds.extents.y;
        gameObject.transform.Find("Image").GetComponent().transform.localScale = new Vector3(canvasSize, canvasSize / ratio, canvasSize);
      }
      if(gameObject.transform.Find("textbg")){
        gameObject.transform.Find("textbg").GetComponent().color = new Color32(255,255,225,132);
      }
      gameObject.transform.Find("Image").GetComponent().sprite = showIcon;
      gameObject.transform.Find("Image").GetComponent().color = new Color32(255,255,225,225);
      gameObject.transform.Find("Image").GetComponent().material = fullItem.GetMaterial();
    }
  }


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *