x


Simulating a Log

Hi, I'm trying to achieve a "Log" for in my game. It's supposed to be a window in my HUD that keeps track of a couple of variables. So I basically want to sent strings with some variables to it once every few minutes.

What kind of GUI element should I use and how could I sent strings to that element?

more ▼

asked May 25 '12 at 04:11 PM

Danzou gravatar image

Danzou
220 16 27 40

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

You can have multiple ones so that it's a "sliding" log, at most shows 3 messages.

http://unity3d.com/support/documentation/ScriptReference/GUIText.html

And then you can just update it by getting the users GUI... If you need more info on it, ask.

more ▼

answered May 25 '12 at 05:43 PM

Justin Warner gravatar image

Justin Warner
6.3k 19 27 65

(comments are locked)
10|3000 characters needed characters left

I would use GUI (or GUILayout) Label for the log. If you have say 4 lines of text you can just use 4 Labels with static positions and change the strings in them when the log changes.

If you wanted the lines of the log to slide in an animation, put everything inside a GUI.Box that clips children and use 1 extra label that's clipped off the bottom. When you add a new line of text, start a coroutine that slides all the labels up one position and when the animation is done, reset the label positions with the new text in each label.

This is more complicated than using a GUI.ScrollView, but you don't want to have an unlimited number of labels since the engine still has to calculate their coordinates every frame and eventually you'll have way too many Labels being drawn that are unseen.

more ▼

answered May 25 '12 at 05:51 PM

Mortoc gravatar image

Mortoc
915 2 6 14

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3680
x418
x342
x67

asked: May 25 '12 at 04:11 PM

Seen: 362 times

Last Updated: May 25 '12 at 05:56 PM