Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 MadToLove · Sep 17, 2012 at 08:55 AM · guitexturepaper

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.

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by MadToLove · Sep 18, 2012 at 10:19 AM

This was exactly what I was looking for. http://answers.unity3d.com/questions/302087/read-notes-like-amnesiapenumbra.html

Comment
Add comment · 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
0

Answer by Kirbyrawr · Sep 17, 2012 at 09:47 PM

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!

Comment
Add comment · Show 2 · 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 Oumlaz · Aug 19, 2014 at 06:52 PM 0
Share

but what is yourobjecttransform ?

avatar image Kirbyrawr · Aug 24, 2014 at 03:12 AM 0
Share

The note object, but actually this script is really old xD

avatar image
0

Answer by sig · Sep 18, 2012 at 06:01 AM

Clues:

  • http://docs.unity3d.com/Documentation/ScriptReference/Input.GetKeyDown.html - use that example to detect if KeyCode.F was pressed

  • http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html - use those examples to detect what object mouse is pointing at (see the last example snippet)

  • Remember to add relevant tags to detect "paper" - http://docs.unity3d.com/Documentation/Components/class-TagManager.html

  • use C#

Good luck!

Comment
Add comment · 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

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

13 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

Related Questions

Is it possible to link character skill lists to a GUI, and if so, how? 3 Answers

C# combining Two Textures 3 Answers

Load a transparent texture by script 1 Answer

How to increase space between two things with GUILayout.BeginHorizontal C# 1 Answer

Gameover function calling before game ends help 2 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