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
1
Question by .ashen_verdict. · Dec 17, 2011 at 11:30 PM · guitextureguitextureinventorytoggle

Toggle GUITexture V.2

Yo! Unity Answers, ( first time here) so i need help with this Toggle Texture thing.

i have this Texture in my Scene which is the Inventory GuiTexture show in Picture1.

http://imageshack.us/photo/my-images/546/gui1.png/

i can toggle it on and off no problem, but the problem is whenever i start my game the Inventory GuiTexture is on ToggleOn mode.

what i need is that the Inventory GuiTexture is on ToggleOff Mode when i start my game, show in Picture2

http://imageshack.us/photo/my-images/842/gui2j.png/

here's the script of Inventory GuiTexture


function Update() {

  if (Input.GetKeyDown(KeyCode.F1)) {

     guiTexture.enabled = !guiTexture.enabled;

     }

}


--thanks to Kith for the script

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

1 Reply

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

Answer by jahroy · Dec 17, 2011 at 11:35 PM

Add this to the Start function of your script:

guiTexture.enabled = false;

It will set the value of guiTexture.enabled to false when your script is enabled.

If you don't have a Start function, you can create one by adding this to your script:

function Start ()
{
    guiTexture.enabled = false;
}

The code inside the Start function gets called one time when your script gets enabled.

 


 

FYI:

The code you already have executes every frame because it's in a function named Update. Every frame it checks whether or not the F1 key is pressed.

If F1 was pressed during the current frame, it executes the code in the if block, which toggles the value of the enabled property of the guiText attached to the GameObject with your script.

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 .ashen_verdict. · Dec 18, 2011 at 07:38 AM 0
Share

Awesome , thanks Jahroy

i added function Start to it.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

GUI.toggle and GUI.horizontalSlider to GUItextures. 0 Answers

GUI texture touch input problem 1 Answer

GUI.DrawTexture on GUI.Button press 1 Answer

GUI_TEXTURE PROBLEM! 2 Answers

change the style of a gui by a key press 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