Search Unity

Question Do UI elements for example Images have GameObject component

Discussion in 'Scripting' started by kader1081, Mar 13, 2023.

  1. kader1081

    kader1081

    Joined:
    Oct 16, 2021
    Posts:
    379
    Hi when I tried to acces a Images gameobject component it said there is no gameobject attached to it
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,692
    kader1081 likes this.
  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,859
    Unless you're talking about
    UnityEngine.UIElements.VisualElements
    and derived types, in which, no, they are not components attached to game objects.

    Make sure you're using the right namespace. It's possible to accidentally use
    UnityEngine.UIElements;
    instead of
    UnityEngine.UI;
    .
     
    Kurt-Dekker likes this.