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 /
This question was closed Mar 25, 2015 at 07:46 AM by Fattie for the following reason:

Duplicate Question

avatar image
0
Question by SujanaUnity · Mar 22, 2015 at 10:50 AM · buttons

can we have chance to put 2 actions for single button?

Draw Texture while clicking button in game window, again if I click that button, texture disappear in game window(this type of action for that button goes on throughout the game)?, is it possible?..If any one have code may u plz provide it.

 if (GUI.Button (Garland, "Garland")) 
 {
 click=true;
  }
 if (click == true) 
 {
 GUI.DrawTexture(GarlandRect,Garl);
 }

after that what I have to write to disappear texture in game window?

Comment
Add comment · Show 1
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 Fattie · Mar 25, 2015 at 07:46 AM 0
Share

You should be using Unity's "new" UI. Do not use "GUI" for any reason, ever.

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by Priyanshu · Mar 22, 2015 at 10:58 AM

What you want is concept of toggling. That is On/Off switch with a single button.

When you press the Button you assign click = true.

Instead assign it as click = !click. Each time you press the button, value of click will switch between true-false.

After that you can write code: If click == true, do this else do that.

Comment
Add comment · Show 3 · 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 SujanaUnity · Mar 23, 2015 at 03:35 PM 0
Share

Thanks for ur answer, I want toggle condition between textures.I mean whenever I click the button draw some texture, if again I click that button null that texture.

if(click==true) drawtexture; else if(click=flase) null that texture;(off that texture in game window)...(again click it draw,another click null it..)

may u plz give code to null the texture.

avatar image Nymisu · Mar 23, 2015 at 03:45 PM 0
Share

All you need to check the material of the object.

 if(yourtargettransform.renderer.material != defaultmaterialname)
 {
   yourtargettransform.renderer.material = defaultmaterialname;
 }
 else yourtargettransform.renderer.material = paintedmaterialname;

Remember to do this onButtonDown/On$$anonymous$$eyDown so it won't fire every time a frame is painted.

Also remember in Unity 5 you need to

 transform.GetComponent<renderer>().material 

ins$$anonymous$$d of transform.renderer.material

avatar image SujanaUnity · Mar 25, 2015 at 07:39 AM 0
Share

thanks, I"ll try it

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

Mobile Button input broken when built for Mac/PC? 0 Answers

Bad automatic navigation between selectables 1 Answer

How do I make buttons that were instantiated at run-time do anything? 1 Answer

Select an enemy to attack with buttons? 2 Answers

UI button not working 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