Search Unity

public Image from c# script dont show up in the inspector

Discussion in 'Scripting' started by modulo34, Aug 2, 2020.

  1. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    I have a strange problem, when trying to add a Image from my script(just started to write it), it don't show up in the inspector, i have try to restart both Unity and VsCode, nothing happen, anyone had this problem?If a had for example ,a public int it work, never had any problem like that before


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UIElements;
    5.  
    6.  
    7. public class UIFade : MonoBehaviour
    8. {
    9.  
    10.     public Image fadeScreen;
    11.     private bool shouldFadeToBlack;
    12.     private bool shouldFadeFromBlack;
    13.     public int test;
    14.  
    dwdwdw.PNG
     
  2. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    Change this:
    Code (CSharp):
    1. using UnityEngine.UIElements;
    To this:
    Code (CSharp):
    1. using UnityEngine.UI;
     
  3. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    Strangely, i dont have this option, i got this message:

    The type or namespace name 'UI' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?) [Assembly-CSharp, Assembly-CSharp]csharp(CS0234)
     
  4. adamgolden

    adamgolden

    Joined:
    Jun 17, 2019
    Posts:
    1,555
    I'm not sure? I did confirm what you said though - public Image doesn't show up in the Inspector (unless that's changed to UnityEngine.UI).

    Maybe check Package Manager and make sure Unity UI is installed?
    unity_ui.jpg
     
  5. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    I think you found the problem ,but i dont have Unity UI??
    fewfewf.PNG
     
  6. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    Just found it in All packages, i will try to reinstall it
     
  7. modulo34

    modulo34

    Joined:
    Sep 13, 2014
    Posts:
    30
    Finally i have upgrade my project to Unity 2020.1.0f1 and that fixed the problem.
     
    adamgolden likes this.