• 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 john-essy · Aug 18, 2011 at 09:33 PM · gui-texture

Call guiTexture

Hi guys i was wandering how i can call a gui texture either by trigger or bollean. The problem i am having is. When i $$anonymous$$t a checkpoint i want a texture to appear on screen then wait 3 seconds and dissapear. Or by trigger so when i am in the trigger show the texture wait the 3 seconds or until i have exited then dissapear here is a small script i have wrote but still doesnt work i get an error (there is no guiTexture attached to the gameObject )

 var checkPic1 : Texture2D;
 
 function OnTriggerEnter($$anonymous$$t : Collider)
 {
     if($$anonymous$$t.gameObject.tag == "Player")
         {
             guiTexture.texture = checkPic1;
         }
 }
 
 function OnTriggerExit (exit : Collider)
 {
     if(exit.gameObject.name == "Player")
         {
             Destroy(gameObject);
         }
 }
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

2 Replies

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

Answer by Scribe · Aug 18, 2011 at 10:17 PM

first make your texture what you want and where you want it on screen to show up then in the inspector click the tick check mark so that it is disabled and doesn't show up, then put t$$anonymous$$s in your script

 var YourTexture : GUITexture;
 
 function OnTriggerEnter($$anonymous$$t : Collider){
     if($$anonymous$$t.gameObject.tag == "Player")
         {
             YourTexture.enabled = true; //make sure you set t$$anonymous$$s to flase in the inspector as I said before else it will do not$$anonymous$$ng
             yield WaitForSeconds(3);
             YourTexture.enabled = false;
         }
 }

Scribe

P.S your getting that error because I presume you attacked t$$anonymous$$s to the checkpoint or trigger collider and you therefore have to chose w$$anonymous$$ch object the GUITexture is. using guiTexture presumes that the script is attacked to a GUITexture object

Comment
Add comment · Show 5 · 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 john-essy · Aug 19, 2011 at 10:19 AM 0
Share

Thanks mate will try that strait away

avatar image john-essy · Aug 19, 2011 at 12:14 PM 0
Share

Thank you soooo much feel like a tit now

avatar image Scribe · Aug 19, 2011 at 03:59 PM 0
Share

I guess it worked in that case :) your welcome

avatar image john-essy · Aug 24, 2011 at 04:41 PM 0
Share

Yea it did thanks now we have all the functions we need and have alos used this to create our menus and by christ they work and look amazing Thanks if we could kiss you we would lol

avatar image Scribe · Aug 26, 2011 at 08:47 AM 0
Share

haha very glad it worked well for you :)

avatar image
0

Answer by corriedotdev · Mar 23, 2013 at 02:10 PM

Hi guys, i had a try of t$$anonymous$$s code but doesnt seem to work at all... i understand that t$$anonymous$$s is ol. I attaacht the gui texture as a c$$anonymous$$ld of the fps camera, disable it. Attach the script to a cube with trigger... i walk through it and not$$anonymous$$ng :/ any idea? Sorry ive tried my own script and failed so i looked on here, t$$anonymous$$s one seems promising, the code looks like it should work :/

Comment
Add comment · Show 5 · 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 Scribe · Mar 23, 2013 at 03:47 PM 0
Share

So there are a few things that you might have set up wrong...

Firstly make sure you have disabled the right box of the GUITexture, you should have the component disabled rather than the object:

GUITexture

If that is how you have it already then make sure your camera is set-up correctly, with a collider, rigidbody, and the tag 'Player'

Camera set-up

Hopefully that solves your issue, here what my trigger looks like as well but I think that ones more obvious

Trigger set-up

Hopefully that fixes your issue, good luck!

Scribe

avatar image corriedotdev · Mar 23, 2013 at 07:48 PM 0
Share

Thanks very much scribe, you have been most helpful to the community. I will try this momentarily, and let you know how it went.

Cheers

avatar image corriedotdev · Mar 23, 2013 at 09:36 PM 0
Share

It still wont work. Ok so i have the standard fps walker. Put the gui a child of the camera, untick the correct place. Attact script to a cube with box collider and trigger ticked. I just need a gui texture to appear when the collider is hit... really annoing me now, ive spent hours trying

avatar image Scribe · Mar 23, 2013 at 09:44 PM 0
Share

Which object in the fps walker has the collider attached, have you set its tag to 'Player'.

Scribe

avatar image corriedotdev · Mar 23, 2013 at 09:45 PM 0
Share

FIXED IT! I did what you recommended but removed the rigid body as it would mess with the fps controller than attached the rest to the fps walker itself not the camera. Thanks again

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

7 People are following this question.

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

Related Questions

update GUI texture when a enemy car dies 1 Answer

gui texture / text depth 1 Answer

Infinite GUI/GUI Texture loop 1 Answer

Detect Mouse Click on GUI Texture (NOT ONGUI) 0 Answers

GUI Texture overlap Click/Tap 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