pop up image from trigger object

Hi,

I’m trying to pop up an image from OnTriggerEnter with box colider trigger. How do I make it work? I’ve tried these scripts from an Ben Pitt answer but it won’t work:

function Update () {
    Hide();
}

function Hide() {
    guiTexture.enabled = false;
}

function Show(paper : Paper) {

    if (!guiTexture.enabled) {
        var t = paper.popupTexture;
        var rect = Rect( -t.width/20, -t.height/20, t.width, t.height );
        guiTexture.pixelInset = rect;
        guiTexture.texture = t;
        guiTexture.enabled = true;
    }   
}

function OnTriggerExit(otherCollider : Collider) {
    Hide();
}

this one on a GuiTexture

and then:

var popupTexture : Texture2D;
private var paperPopup : PaperPopup;

function Start () {
    paperPopup = FindObjectOfType(PaperPopup);

    if (popupTexture == null) {
        popupTexture = renderer.material.mainTexture;   
    }
}

function OnTriggerEnter(otherCollider : Collider) {
    paperPopup.Show(this);
}

this script I’ve puted on a trigger object

Can anyone help?

Try this on the object that collides:

private var paperPopup : PaperPopup;

function Start () {
    paperPopup = FindObjectOfType(PaperPopup);
    if (paperPopup)
      paperPopup.renderer.enabled = false; // hide
}

function OnTriggerEnter(otherCollider : Collider) {
    if (paperPopup)
      paperPopup.renderer.enabled = true; // show
}

You might want to implement OnTriggerExit to turn it off again.

Be sure you read this: http://unity3d.com/support/documentation/ScriptReference/Collider.OnTriggerEnter.html
If all those conditions aren’t met, it won’t work. You may want OnColliderEnter instead.

I found out the problem: the GUItexture starts off and it won’t turn ON when triggered. But the texture changes.