Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by KravenArk · Feb 23, 2013 at 12:15 AM · guiscreendocuments

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.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nventimiglia · Feb 23, 2013 at 12:17 AM 1
Share

Are you joking ?

avatar image hoy_smallfry · Feb 23, 2013 at 12:29 AM 0
Share

@nventimiglia After a few weeks on this Q&A, I'm not surprised if it's not a joke.

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

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

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image KravenArk · Feb 23, 2013 at 02:19 AM 0
Share

Ty so much

avatar image KravenArk · Feb 23, 2013 at 02:35 AM 0
Share

Ok so i have a camera and the document. Do i attach it to the camera or the document.

avatar image KravenArk · Feb 23, 2013 at 03:19 AM 0
Share

![alt text][1]

I got this error when i put it in [1]: /storage/temp/8195-error.png

error.png (21.7 kB)
avatar image yusolaifdfer · Feb 23, 2013 at 03:30 AM 0
Share

add this on the top xD

 var iWantToSeeDocument : boolean = false;
avatar image AlucardJay · Feb 23, 2013 at 05:10 AM 1
Share

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.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Making a start screen in Unity 3 Answers

Unity 3d C# GUI box goes off to the side needs to be in the center of the screen 0 Answers

One Last GUI Question 1 Answer

HorizontalScrollbar not appearing in GUILayout.BeginScrollview C# 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges