• 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
Question by Entyro · Jul 30, 2013 at 08:39 PM · guitexturepopuppaper

Problem vid GuiTexture

Hello! I have a problem with my paper popup script. When I walk up to a paper, a text pops up "[E] Read note", when pressing "E" a GuiTexture pops up, and when you left click it closes.

The problem I have is when there's multiple notes around the map. It seems that I can only pick up one note, because when I try to pick up a second one, it just disappears.

Does anyone no what the problem is?

//Paper.js

 private var buttonInRange = false;
 var note : AudioClip;
 public var popupObject : GameObject;
 public var guiSkin : GUISkin;
 
 private var popupScript : PaperPopup;
 
 function Start ()
 {
     popupScript = popupObject.GetComponent(PaperPopup);
 }
  
  
 function OnTriggerStay (c : Collider)
 {
     buttonInRange = true;
 }
 function OnTriggerExit (c : Collider)
 {
     buttonInRange = false;
 }
 function OnGUI()
 {
     if(buttonInRange == true)
     {
         GUI.skin = guiSkin;
         GUI.Label (Rect (Screen.width/2-50, Screen.height/2-55, 120, 50),"[E] Read note");
     }
 }
 
 function Update ()
 {
     print(gameObject+" buttonInRange = "+buttonInRange);
     
     if(buttonInRange == true)
     {
         if (Input.GetKeyDown ("e"))
         {
             print(popupScript+" is showing");
                AudioSource.PlayClipAtPoint(note, transform.position);
                popupScript.Show();
                Destroy (gameObject);
         }
     }
 }


//PaperPopup.js

 public var paperObject : Texture2D;
 
 function Start()
 {
     Hide();
 }
 
 function Hide()
 {
     guiTexture.enabled = false;
 }
 
 function Show()
 {
     if (!guiTexture.enabled)
     {
         var rect = Rect( -paperObject.width/3, -paperObject.height/2, paperObject.width, paperObject.height );
         guiTexture.pixelInset = rect;
         guiTexture.texture = paperObject;
         guiTexture.enabled = true;
     }   
 }
 
 function OnMouseDown ()
 {
     Hide();
 }



alt text alt text

1.jpg (271.4 kB)
2.jpg (238.2 kB)
Comment

People who like this

0 Show 15
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 perchik · Jul 30, 2013 at 08:47 PM 0
Share

What do you mean by

when I try to pick up a second one, it just disappears

Which note disappears, what happens?

avatar image Entyro · Jul 30, 2013 at 08:57 PM 0
Share

If I have a second note somewhere in the world and try to pick it up, the note disappears and the GuiTexture doesn't show up as it did with the first note. It seems that "Note1" (image above) only shows the Texture. It doesn't matter witch note you choose to read first, you can only read "Note1".

avatar image perchik · Jul 30, 2013 at 09:00 PM 0
Share

The only thing that seems odd to me is the call to Destroy() but I don't think that should cause your problem. Perhaps try commenting out that line though?

avatar image Entyro · Jul 30, 2013 at 09:06 PM 0
Share

Still wont show. Shows everytime on "Note1" but not on the other ones.

avatar image perchik · Jul 30, 2013 at 09:07 PM 0
Share

silly question, but can you verify the other note objects have the scripts attached and enabled?

Show more comments

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

16 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 avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Show GUITexture by picking an item. 0 Answers

Collecting paper won't work 1 Answer

OnMouseDown Range Problem 1 Answer

'sendMessage' is not a member of 'unityengine.transform' 1 Answer


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