In scripting, what's a UI Image called

I have a code that’s supposed to turn a UI Image on and off when an input is held. Here’s my script…

var aimTexture : Image;
function Update() {
    // Only enable aim texture when 'Aim' button is not pressed.
    // In this case I have used 'Shift' key for this.
    if (Input.GetButton("Aim"))
        aimTexture.enabled = true;
    else
        aimTexture.enabled = false;
}

But, I’m not sure what to put for my variable. Like I said before, I want it to be a UI Image… What would I put?

What do you mean by “put”? Do you want to set it via Inspector or just from other script? Anyway look at this link maybe it will help you: https://unity3d.com/ru/learn/tutorials/modules/beginner/ui/ui-image

I meant what would I put as the variable so that it represents a UI Image. It’s where I wrote “Image” in the code

Just drag the GameObject that has the Image component to the aimTexture Image slot in the inspector

No. What I’m talking about is, “Image” doesn’t work. What do I put instead of image so that it works with UI Images

ah I know what you did you

you probably forgot to add

import UnityEngine.UI;

at the top of your script

1 Like

Oh, okay. I just recently updated to Unity 4.6, so I’m still getting used to switching from GUI to UI