Trying to view paper object on button press GUI Texture

Trying to get it so when the player is within distance of a “paper” object, looking at it and hits the F key it will display a GUI texture to the screen then you can hit F (or any other key if needed) again to exit. Also one with the same functionality but a little added to it.

READ PAPER EXAMPLE 1: Character see’s paper on a desk, when they are within 5’ of this object and are looking at it and hit the F key it pops a GUI texture of the paper on the screen when they hit F again it exits.

READ PAPER/LOAD LEVEL EXAMPLE 2: Character see’s paper on a desk, when they are within 5’ of this object and are looking at it and hit the F key it pops a GUI texture of the paper on the screen then when they hit F again it exits and loads character to another level.

If they cannot use the same button F for looking at the GUI texture AND exiting that is fine to substitute a different key press.

If you answer since I suck at scripting/programming in general please state specific’s and please let me know if it C# or Java.

Thank you ahead of time for any and all help.

Okey NO one is born knowing, but I suggest you to look a tutorial:

I can share with you my script

#pragma strict
var YOUROBJECTTransform : Transform;
private var Gui = false;


function OnMouse()
{
    if(Vector3.Distance(YOUROBJECTTransform.position, transform.position) > 4) return;
    Gui = true;
    
}
function OnGUI(){
if(Gui == true){
if(GUI.Button(Rect(650,150,100,50), "OPEN THE PAPER")){
  //DO YOUR ACTION HERE

}
 if(Vector3.Distance(YOUROBJECTTransform.position, transform.position) < 4) return;
 Gui = false;

}
}

You need to attach this script to your character , when the character is near the object (paper or anything) and the mouse is over the object , gui pop out with a button , if you touch this button you can perform an action like guitext from the paper or anything you want

Hope it helps ^^

//IS JAVASCRIPT OR JS!

Clues:

Good luck!

This was exactly what I was looking for. read notes like amnesia/penumbra - Questions & Answers - Unity Discussions