Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

public Image not show in Inspector

Discussion in 'Scripting' started by gamer123454321, Aug 1, 2020.

  1. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    Hi! In script I tried to public different type of variable, they all show in Inspector except Image. Can Anyone Help?
     
  2. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    try to use :

    Code (CSharp):
    1. [SerializeField] public Image test;
     
  3. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    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
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Do you have any compile errors in your console?
     
  5. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    No error. Game is playable
     
  6. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Can you share the whole script and a screenshot of the inspector?
     
    Bunny83 likes this.
  7. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    even sprite works fine
    question.png question2.png
     
  8. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Replace
    Code (CSharp):
    1. using UnityEngine.UIElements;
    with
    Code (CSharp):
    1. using UnityEngine.UI;
     
    Last edited: Aug 17, 2022
  9. gamer123454321

    gamer123454321

    Joined:
    Mar 25, 2020
    Posts:
    83
    It works. Thank yo so much!!:)
     
  10. LordVise

    LordVise

    Joined:
    Aug 1, 2020
    Posts:
    7
    Brilliant! Have been battling with this for hours. Thanks for posting the solution.
     
  11. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,524
    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 ^^.
     
  12. kaplovski

    kaplovski

    Joined:
    Sep 16, 2013
    Posts:
    2
    That UnityUI does not exist in my Unity version
     
  13. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,143
    Make sure you have the Unity UI package installed.
     
  14. twannyb

    twannyb

    Joined:
    Mar 2, 2023
    Posts:
    1
    Helped me not yeet my computer out of the window, ty haha