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 esitoinatteso · Oct 02, 2013 at 10:24 PM · guionguidisplaystyle

onGUI style silly problem

Hi there! Ok so, this is really a basic question, I don't know what I did wrong here: I followed Unity's Doc Tutorials and a couple on youtube, difference is they get things done, I don't!

In my first Scene I made a plane and I attached to it a 2d texture, I'm using it as a background. I also attached it a script for a simple GUI in which I plan to store one button to make Unity Load another Scene... I thought that would have been the difficult part but then I stumble upon this problem:

 using UnityEngine;
 using System.Collections;
 
 public class GUIMenu : MonoBehaviour {
     
     public GUIStyle customBox;
     
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     
     // Many Things concerning GUI...
     void OnGUI(){
         
         GUI.Label(new Rect(250,150,750,100)," Look! A stylized slice of GUI!","customBox");
     }
 }

So... I went to the inspector, eager to assign my 2d texture to this customBox I declared, I did so and then nothing happens. I mean, I play start and something do happen: no simple rectangle appears, and text is somehow paint in red...

This means something is working somewhere but then why my image is not displayed?

If it's a matter concerning the 2d texture I'm trying to apply let me know, because in this case I'll edit my question to include more details. Thanks for the patience, it must be my bad but I can't find the error by myself!

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

Answer by TrickyHandz · Oct 02, 2013 at 11:00 PM

The problem probably exists here:

 GUI.Label(new Rect(250,150,750,100)," Look! A stylized slice of GUI!","customBox");

You should be getting some console warnings on this that say something like "Unable to find style "customBox" in skin 'GameSkin' Repaint

You need to take the quotes off around customBox, so that it refers to the variable you declared:

 GUI.Label(new Rect(250,150,750,100)," Look! A stylized slice of GUI!",customBox);

This way it refers to the custom GUIStyle you defined and doesn't try to read it from the default skin.

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 esitoinatteso · Oct 02, 2013 at 11:09 PM 0
Share

Holy $$anonymous$$oley you're so damn right about this! $$anonymous$$any many thanks, I knew I was missing something! It works! Now I'm going to get me some sleep, my brain must be pooped.

avatar image TrickyHandz · Oct 02, 2013 at 11:10 PM 0
Share

No problem. Happy coding!

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

15 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

Related Questions

How expensive is Rect.Contains(Event.current.mousePosition)? 1 Answer

Display problem with OnGUI 3 Answers

Display text with unknown length? 1 Answer

Can't display PNG texture within GUI calls 1 Answer

Displaying Z Rotation through script 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