On trigger, GUI texture appear

I am trying to make a Texture to be shown when you stay in a collider.
Example:
The player enters the collider
A texture appears in the screen and stay there
The player exit the collider
The texture disappear

I have found ONLY ONE script about this in the internet, and it was made in an older version of unity, so it doesn’t work. Why? I don’t know, because unity hasn’t said anything about it like “this script is old, let me help” and there’s no errors, but it just doesn’t work. I don’t know how, i don’t know why, it simply not works. Can anyone help me?

I’m not entirely sure what you mean by making a texture appear on the screen. Do you mean an icon, and image, or some text appearing somewhere on the screen whenever you’re in the trigger’s collider?

Either way, this is the code you’d use to catch the trigger events. You need to make sure that the collider has the IsTrigger box enabled for it to work. You can also check the “col” object being passed into the trigger event to make sure it’s the trigger object you want:
e.g.,
if(col.name == “FloorSwtich”){ … }
of
if(col.tag == “FloorSwtich”){ … }

If you want something to appear on the UI you can enable and disable objects on the canvas, or add/remove different components to it.
The section of the Unity docs has more info on UI images (https://docs.unity3d.com/ScriptReference/UI.Image.html). It might be better to create a canvas prefab with the image on it already, and then just enable and disable the image (or the canvas) whenever the trigger events occur.

   void OnTriggerEnter(Collider col)
    {
        // Add / enable texture
    }

    void OnTriggerExit(Collider col)
    {
        // Remove / disable texture
    }

Post the script you found.