- Home /
Cant acces an image icon from class
So When i press play im getting only the white background but not the item icon that is supposed to be on it. My theory is that for some reason I cant access the Sprites in Items folder, but i don't really know what's the real problem.
I Couldn't upload the third screen of the code and thought they are all important to my question so i copied and pasted the last one.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class UIItem : MonoBehaviour { public Item item; private Image spriteImage;
 private void Awake()
 {
     spriteImage = GetComponent<Image>();
     //One slot at the start for the testing purposes
     UpdateItem(null);
 }
 //Hiding an item
 public void UpdateItem(Item item)
 {
     this.item = item;
     if(this.item != null)
     {
         spriteImage.color = Color.white;
         spriteImage.sprite = this.item.icon;
         Debug.Log("if");
     }
     else
     {
         spriteImage.color = Color.clear;
         Debug.Log("else");
     }
 }
 
}
alt text

Your answer
 
 
             Follow this Question
Related Questions
Cant access the Image icon from class 1 Answer
Problem with Line Renderer 1 Answer
How to change the sprite and the animator in script to make a character selection? 2 Answers
how to use onmousedown() or onmouseup() unity on local multiplayer/vs mode? 0 Answers
how do I find out which object is closer to the finish line? 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                