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 D3m0nE · Feb 26, 2013 at 12:53 PM · guiguilayoutlabelicon

GUILayout Icon + Text

Hello Everybody

I Have a GUILayout.label("WhatEver"); i just need add Icon To This Label

i followed this Link

link text

But the Problem That its need 2 Label Is there way to make it in 1 Label? and Thanks

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by GuyTidhar · Feb 26, 2013 at 01:36 PM

You can either define a GUIStyle from within the code

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

Or define the 'Label' guistyle in a new GUISkin

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

This way you could define a background image for the label, and offset the text if needed.

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 D3m0nE · Feb 26, 2013 at 03:07 PM 0
Share

You Didnt Get It -.- I Need GUILayout.Label Contain a TEXT And ICON

avatar image GuyTidhar · Feb 26, 2013 at 03:11 PM 0
Share

I did.

If you'd set the GUILayout.Label with the GUIStyle which is defined with an image as background for 'normal' status, you will get that image - your icon.

If you don't want the icon to be directly behind the text, you can , from within the GUIStyle, offset the text.

You could also, just set the 'Label' item in a GUISkin you create in your project the same way, then set

 GUI.skin = yourSkinReference;

Right before calling:

 GUILayout.Label("WhatEver");

This will draw the label with the style you have defined in the inspector.

Again, take a look at this:

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

avatar image
0

Answer by ptyalisme · Jun 25, 2014 at 07:40 PM

I got the same problem, here my solution, hope it help other people.

http://docs.unity3d.com/Manual/gui-Basics.html

 public Texture2D icon;
 
 void OnGUI () {
      GUI.Box (new Rect (10,10,100,50), new GUIContent("This is text", icon));
 }
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
avatar image
0

Answer by Prosto_Lyubo · Nov 12, 2017 at 07:41 PM

This generates single label that looks at the player. Image is on the left of the text.

 private void OnDrawGizmos(){
     GUIContent gUIContent = new GUIContent( "text",                 
      EditorGUIUtility.FindTexture( "Animation.Record" ) );
     Handles.Label( this.transform.position, gUIContent );
 }
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

12 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

Related Questions

Fade out GUILayout Area? 1 Answer

Why does old text in GUILayout not disappear? 1 Answer

For Loop GUILayout.Label Problems 1 Answer

GUI labels and buttons overlapping | how can I fix this? 2 Answers

GUILayout Sort Problem 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