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 MikezNesh · Jun 24, 2010 at 08:50 AM · timerlabelgraphicgui-window

How do you add graphics and features to a GUI Window?

How do you add graphics to a GUI Window? For example: a background.

Also how do you add a 3D Text or label thing into a GUI Window?

EDIT: (ADDED CODE)

var endTime : float;

var textMesh : TextMesh;

var boolean = false; var windowRect = Rect(0,0,360,480);

function Start() { endTime = Time.time +60;

 textMesh = GameObject.Find ("Timer").GetComponent(TextMesh);

 textMesh.text = "60";

}

function Update () {

 var timeLeft : int = endTime - Time.time;

 if ( timeLeft < 0)
 {
     timeLeft = 0;
     boolean = true;
 }
 textMesh.text = timeLeft.ToString();

}

function OnGUI() {

 if(boolean) GUI.WIndow (0, windowRect,DoMyWindow, "My Window");

}

function DoMyWindow (windowID : int) {

 if( GUI.Button(Rect(10,20,100,20),"HelloWorld"))  
 print ("Got a click");

}

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

Answer by Mike 3 · Jun 24, 2010 at 08:56 AM

When you call the window function, you need to pass a function to it as a parameter

That function gets called when the window draws

What you need to do is add your Label into that function, and it should just draw it, with the coordinates starting at 0,0 for the top left of the window

To draw a background, use GUI.DrawTexture in that function with the same size as the window and 0,0 for x and y

Edit:

To make your window only show when you trigger it, you can just use a bool to set whether to draw or not

//at the top of the script var yourBool = false;

//the code which is going to draw the window if (yourBool) GUI.Window(blah blah);

//in the trigger yourBool = true;

Comment
Add comment · Show 19 · 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 MikezNesh · Jun 24, 2010 at 08:59 AM 0
Share

How can I on trigger pop out this window?

avatar image Mike 3 · Jun 24, 2010 at 09:04 AM 0
Share

Edited the answer to answer that

avatar image MikezNesh · Jun 24, 2010 at 09:05 AM 0
Share

One more question: do you know any easier ways of doing a pop up window?

avatar image Mike 3 · Jun 24, 2010 at 09:12 AM 0
Share

Nope, all the ways I can think of are more difficult ;D

avatar image MikezNesh · Jun 24, 2010 at 09:24 AM 0
Share

:D funny. Could you make your bool script more precise because I'm a bit confused. I've got my GUI window going and all but the bool part is confusing.

Show more comments

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

No one has followed this question yet.

Related Questions

How Would I Make A GUI Label Fade After A Certain Amount Of Time? 1 Answer

Creating time elapsed label, in js? 1 Answer

Timer Between Labels 2 Answers

how to make global labels in front and GUI.BringWindowToBack(ID); 1 Answer

gui label on/off with timer 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