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 Coreyf716 · Sep 01, 2012 at 12:42 AM · javascriptguibuttontexttransparency

Gui Button Solid

I am using the following script to make a gui button. How can I edit the transparency of this button?

 function OnGUI () {
      if (GUI.Button (Rect (25, 25, 500, 50), "Play")) {
 }
Comment
Add comment · Show 6
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 · Sep 01, 2012 at 09:24 AM 0
Share

your question heading sounds like a new game title! :)

avatar image Coreyf716 · Sep 01, 2012 at 04:16 PM 0
Share

It does? How so?

avatar image Fattie · Sep 01, 2012 at 04:30 PM 0
Share

goodness, you don't know who Hideo $$anonymous$$ojima is ?!

that would be like being an aspiring filmmaker and not knowing about Jaws or Pretty Woman ! heh !

"$$anonymous$$etal Gear Solid", 10 million sales, top ten or twenty game of all time. It is a, or I suppose the, "s$$anonymous$$lth" title. (a "s$$anonymous$$lth" is like an FPS but you can hide behind boxes.) (personally, i have no interest in fps, they are silly, but it's a masterwork of course)

http://blogs.ocweekly.com/heardmentality/2010/03/the_5_most_badass_japanese_game_designers.php

avatar image Coreyf716 · Sep 01, 2012 at 04:32 PM 0
Share

No, sorry, I haven't.

avatar image Fattie · Sep 01, 2012 at 04:36 PM 0
Share

O$$anonymous$$ "$$anonymous$$etal Gear Solid" is an incredibly famous video game, and your question title "Gui Button Solid" sounds humorously similar. You rock.

Show more comments

2 Replies

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

Answer by Bunny83 · Sep 01, 2012 at 12:52 AM

By using another skin. The transparency is part of the button texture itself. You can design your own buttons by creating a custom GUISkin and replace the textures with your own.

To use your skin you need to tell Unity to use it in OnGUI.

 var mySkin : GUISkin; // assign your skin in the inspector
 
 function OnGUI ()
 {
     GUI.skin = mySkin;
     if (GUI.Button (Rect (25,25,500,50), "Play"))
         // ...
 }

Comment
Add comment · Show 7 · 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 landon912 · Sep 01, 2012 at 12:56 AM 0
Share

Also if you use different styles then delete "GUI.skin = mySkin;" And add mySkin to the button ie: if(GUI.Button(Rect(25,25,500,50), "Play", mySkin))

avatar image Coreyf716 · Sep 01, 2012 at 12:59 AM 0
Share

I used this script, however the button appears unchanged.

avatar image Eric5h5 · Sep 01, 2012 at 01:05 AM 0
Share

You need to actually make a new skin. Or a new style.

avatar image Coreyf716 · Sep 01, 2012 at 01:08 AM 0
Share

I know. I made the GUI Skin and attached it to the button.

Would I have to add a texture to the background to make the button solid?

avatar image Bunny83 · Sep 01, 2012 at 03:46 AM 0
Share

@Coreyf716: Exactly! As i said the background texture for most default gui elements is a transparent texture. Also the default skin is quite simple you can probably make a way better one ;)

@landon91235: You can't use a GUISkin as parameter for any GUI function. You can pass a certain GUIStyle, but this has to be created somewhere. Either use a certain style from a GUISkin or create the style manually via code. A GUISkin is much simpler most the time. You can also define custom styles in a Skin and just use the style name in the button.

 GUI.Button (Rect (25,25,500,50), "Play", "mycustomstyle");

mycustomstyle needs to be defined in the current skin.

Show more comments
avatar image
0

Answer by Eric5h5 · Sep 01, 2012 at 12:49 AM

Make a new style or skin with a solid button texture and use that in the button.

Comment
Add comment · Show 2 · 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 Coreyf716 · Sep 01, 2012 at 12:50 AM 0
Share

I am new to Unity code. I'm unsure of how to code the skin to react on click.

avatar image Eric5h5 · Sep 01, 2012 at 12:53 AM 0
Share

See the Unity docs for GUI code; everything is explained in detail.

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

11 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

Related Questions

GUIText Problem With MENU 1 Answer

Move the text in a GUI Button/Box 1 Answer

Gui Text Script 4 Answers

Alpha not working in GUITex 0 Answers

GUI Button Disappearing 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