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 Tommy · Oct 17, 2010 at 04:06 PM · guitextureclickdisplayshowstatement

Display GUITexture if statement is true.

Basicly what the title says. I need to show a GUI texture when a IF statement is true, if the statement is false, the GUI texture should be hidden. Example:

   if ( electromilk == true )
   {
    //Show the GUITexture 
   }

How do i display the GUI texture only when the statement is true?

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
1
Best Answer

Answer by Eric5h5 · Oct 17, 2010 at 04:27 PM

guiTexture.enabled = true;

Comment
Add comment · Show 1 · 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 Tommy · Oct 17, 2010 at 04:35 PM 0
Share

Okay, good. Now, that only works if the statement that is supposed to be true is in a script attached to the GUI texture, right? Is it possible to choose what GUI texture to show when the statement is true? Sorry for poor description in first post.

avatar image
0

Answer by TSSTUDIOS · Jan 13, 2014 at 04:40 AM

assint publlic variables to diferent textures ill make this script for other textures ill post ina bit what im gonna make is

if pause guitexture pressed, hide play mode gui and show game object(pause menu)

 private var hit : RaycastHit;
 private var options : boolean = false;
 
 
 public var optionsTexture : GUITexture;
 
 
 public var pausemenuobj : Transform;
 public var mobilebuttons : Transform;
 
 
 
 
 function Start () {
 
 }
 
 function Update()
     {
                 var touches = Input.touches;
                     
                 //detect which mobile buttons are pressed and make decisions accordingly
                 for (var touch in touches)
                 {                            
                     if(touch.phase != TouchPhase.Canceled && touch.phase != TouchPhase.Ended)
                     {                                                                                            
                         if(optionsTexture.HitTest (touch.position)) 
                         //    pausemenuobj.renderer.enabled = true;
                             pausemenuobj.active = true;
                             mobilebuttons.active = false;                    
                     }
                     
                 }
                 
                 if(Input.touchCount == 0)
                 {
                     
                 }
             
             else
             {
         
                 //----------------------------------
             }
                  
 
 }
 function OnMouseDown () {
         //    pausemenuobj.renderer.enabled = true;
                             pausemenuobj.active = true;    
                             mobilebuttons.active = false;        
     }
 



As u can see my mobilebuttons is a transform which means its a game objects not a gui texture, what i did was drag all my guitextures inside that game object, so when i disable the game object all the children will get disabled too, im choosing a game objects because i have been having problems with gui textures theere shoulçd be a layer system like in photoshop, anyway, this is one way u can go at it, there are many ways u can hide labels or u can cript what u wanan hide, or do it like me and select it on the inspector

aw btw this script is ready for mobiel touches and on mouse down do u can test the code one ur computer :)

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

1 Person is following this question.

avatar image

Related Questions

GUITexture Button? 1 Answer

How do I script a GUI Texture as a button, if it's being called from a public variable? [C#] 1 Answer

Need Help on showing GUI Textures on click 0 Answers

Displaying multiple GUITextures On One Camera 0 Answers

Two Overlapping GUITexture Click Detection Problem 0 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