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 karthees · Dec 26, 2013 at 05:05 AM · buttonbackgroundlabelurl

Remove button background

I have 2 button on screen. I need to remove background for only one button. But when i use below it removing all the button background. I need to use button skin for start button. I have another button is www.serverurl.net. Here i need to remove background skin.

 using UnityEngine;
 using System.Collections;
 
 public class Aboutscreen : MonoBehaviour {
 
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     
     
     void OnGUI()
     {
         
         GUI.backgroundColor = Color.clear;
         
         
          GUI.Label(new Rect(10f, 30f, 300f, 50f), "1.Print the alphabet image targets located at");
         
          GUI.Label(new Rect(10f, 60f, 300f, 50f), "2.Point any of the animal images");
         
          GUI.Label(new Rect(10f, 100f, 300f, 50f), "3.Finally your kids able to see the 3D animal render on the screen with soundss");
         
         
         if(GUI.Button(new Rect(260,15,120,50), "www.serverurl.net")) {
             
                 
             
         Application.OpenURL("http://www.serverurl.net");
         }
         
         
         if(GUI.Button(new Rect(80,180,80,40), "start")) {
             
                 
          Application.LoadLevel("25Nov1");    
         
         }
         
         
     }
     
 }
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 robertbu · Dec 26, 2013 at 05:11 AM

Just save and restore the background color:

 using UnityEngine;
 using System.Collections;
 
 public class Aboutscreen : MonoBehaviour {
 
     void OnGUI() {
         Color c = GUI.backgroundColor;
         GUI.backgroundColor = Color.clear;
 
         GUI.Label(new Rect(10f, 30f, 300f, 50f), "1.Print the alphabet image targets located at");
         GUI.Label(new Rect(10f, 60f, 300f, 50f), "2.Point any of the animal images");
         GUI.Label(new Rect(10f, 100f, 300f, 50f), "3.Finally your kids able to see the 3D animal render on the screen with soundss");
 
         if(GUI.Button(new Rect(260,15,120,50), "www.serverurl.net")) {
             Application.OpenURL("http://www.serverurl.net");
         }
 
         GUI.backgroundColor = c;
 
         if(GUI.Button(new Rect(80,180,80,40), "start")) {
             Application.LoadLevel("25Nov1"); 
         }
     }
 }

Alternately, you could reorder your button calls. I did the save and restore above because you cannot always reorder things when you are layering. But in this case:

 using UnityEngine;
 using System.Collections;
 
 public class Aboutscreen : MonoBehaviour {
 
     void OnGUI() {
 
         GUI.Label(new Rect(10f, 30f, 300f, 50f), "1.Print the alphabet image targets located at");
         GUI.Label(new Rect(10f, 60f, 300f, 50f), "2.Point any of the animal images");
         GUI.Label(new Rect(10f, 100f, 300f, 50f), "3.Finally your kids able to see the 3D animal render on the screen with soundss");
 
         if(GUI.Button(new Rect(80,180,80,40), "start")) {
             Application.LoadLevel("25Nov1"); 
         }
 
         GUI.backgroundColor = Color.clear;
     
         if(GUI.Button(new Rect(260,15,120,50), "www.serverurl.net")) {
             Application.OpenURL("http://www.serverurl.net");
         }
     }
 }
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 karthees · Dec 26, 2013 at 05:17 AM 0
Share

which code should i use?

avatar image robertbu · Dec 26, 2013 at 05:23 AM 0
Share

Both will work. The second is a bit less code. @azmat786n's solution below will also work.

avatar image karthees · Dec 26, 2013 at 06:13 AM 0
Share

It's working. But why my text's are too small. See the image

alt text

photo.png (21.1 kB)
avatar image robertbu · Dec 26, 2013 at 06:39 AM 0
Share

You are looking for GUIStyle and/or maybe GUISkin. I use EZGUI (a third-party technology) for my GUI, not the build-in gui stuff. So my experience with GUI is limited. Here are some links:

http://docs.unity3d.com/Documentation/ScriptReference/GUIStyle.html

http://docs.unity3d.com/Documentation/Components/class-GUIStyle.html

After reading the links, if you cannot figure it out, I suggest you open a new question.

avatar image azmat786n · Dec 26, 2013 at 01:07 PM 0
Share

@robertbu thanks buddy and @karthees simply use GUIStyle and assign a font with custom font size its very easy to increase the size of font..

avatar image
0

Answer by azmat786n · Dec 26, 2013 at 05:17 AM

   using UnityEngine;
   using System.Collections;
      
   public class Aboutscreen : MonoBehaviour {
      
 
     public GUIStyle emptyButtonStyle;
      
      
     void OnGUI() {
       //now this button should transparent
       //whenever you assign emptyButtonStyle to a button that's background should transparent
       if(GUI.Button(new Rect(260,15,120,50), "www.serverurl.net", emptyButtonStyle)) {}
      
       //this button have no style assigned therefore its look like unity default button style
       if(GUI.Button(new Rect(80,180,80,40), "start")) {}
      
     }
   }
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

19 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

imaged text button 2 Answers

Creating a component from a button click 1 Answer

Why is my character unlock screen button re-enabling after unlocking a different character? 0 Answers

How do I get an invisible object on canvas to fire OnMouseClick or an Event trigger? 2 Answers

Text is too small while displaying in device 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