Hi! In script I tried to public different type of variable, they all show in Inspector except Image. Can Anyone Help?
try to use :
[SerializeField] public Image test;
still not working either with [SerializeField] or not
public Image test; this code work on other scripts but not work on GameManager script or the script I’m work on
Do you have any compile errors in your console?
No error. Game is playable
Can you share the whole script and a screenshot of the inspector?
even sprite works fine
Replace using UnityEngine.UIElements;
with using UnityEngine.UI;
It works. Thank yo so much!!
Brilliant! Have been battling with this for hours. Thanks for posting the solution.
Hopefully it’s clear what the issue was ^^. You essentially grabed your kid’s toy hammer instead of the actual steel hammer and wonder why you can’t drive the nail in Of course this is a bad analogy because I don’t want to play down the Image class from the UIElements namespace. Though the point is that it’s just the completely wrong image class that you’re looking for. Unity has several UI systems. Have a look at this page to see a rough comparison between the different systems. Of course there are logical naming overlaps between the system. That’s why we have namespaces to distinguish them. Like you may have different boxes of screws. If you grab the wrong box, you get the wrong screw ^^.
That UnityUI does not exist in my Unity version
Make sure you have the Unity UI package installed.
Helped me not yeet my computer out of the window, ty haha
uhh…
You probably have both using UnityEngine.UI
and using UnityEngine.UIElements
in your script, meaning your code editor can’t determine which one to use.
Either remove the using
you you don’t need (likely the latter), or use the namespace qualified name for your usage of Image.
Though you could’ve just googled the error and come to this answer.