- Home /
Make a document pop up on screen
ok...this may be a bit confusing...so i will try to dumb it down. I have a model called "document". i want the gui of the player to show text on-screen when the player wanders over "document". Can someone please write the script for that...my new game will not make sense without this...thank you all so much.
@nventimiglia After a few weeks on this Q&A, I'm not surprised if it's not a joke.
Answer by DryTear · Feb 23, 2013 at 02:12 AM
var iWantToSeeDocument : boolean = false;
var Document : Rect = Rect(Screen.width /2, Screen.height / 2, 300, 600);
var DocName : string = DocumentPage;
function OnTriggerEnter(col : Collider){
if(col.gameObject.tag == "Document")
{
iWantToSeeDocument = true;
}
else
{
iWantToSeeDocument = false;
}
}
function OnGUI(){
if(iWantToSeeDocument == true)
{
Document = GUILayout.Window(0, Document, ShowDocument, ""+DocName);
}
}
function ShowDocument(windowID : int)
{
GUILayout.Label(Rect(0,0,10,10), "Line1");
}
Attach this to the player
Set your DocumentModel a tag called "Document"
And have a collider with isTrigger set to true
To have multiple lines just copy paste the GUILayout.Label onto next lines
Ok so i have a camera and the document. Do i attach it to the camera or the document.
![alt text][1]
I got this error when i put it in [1]: /storage/temp/8195-error.png
add this on the top xD
var iWantToSeeDocument : boolean = false;
There are 2 errors in this answer
1/ as stated above, this line is in C# :
var iWantToSeeDocument : bool;
and this is how it should be :
var iWantToSeeDocument : boolean = false;
2/ the GUI function is not cast correctly, this is the line above :
function OnGui(){
and this is what it should be :
function OnGUI(){
@DryTear : Please make sure your answers are correct (and in the one language) for all future readers.