playMaker

Author Topic: How do you align a GUILayout Text Label?[SOLVED]  (Read 18256 times)

brisck1

  • Playmaker Newbie
  • *
  • Posts: 40
How do you align a GUILayout Text Label?[SOLVED]
« on: December 17, 2013, 11:49:08 AM »
Hi

So im bashing my head against a brick wall trying to figure out something im sure is fairly simple, but after searching the forums extensively, I decided to ask here:

I'm trying to simply align a GUI Text Label to the bottom center of the screen instead of the top-left, which seems to be the default behaviour.

See image for more info: http://imgur.com/DofQGN9

I cant find anything within Playmaker which allows me to do this, nor in the GUI skin options for Label (Just text alignment)
« Last Edit: December 18, 2013, 09:41:20 AM by jeanfabre »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: How do you align a GUILayout Text Label?
« Reply #1 on: December 17, 2013, 11:57:47 AM »
Hmm, I haven't done this myself. Does this thread help?

http://hutonggames.com/playmakerforum/index.php?topic=5489
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

brisck1

  • Playmaker Newbie
  • *
  • Posts: 40
Re: How do you align a GUILayout Text Label?
« Reply #2 on: December 17, 2013, 12:10:16 PM »
Saw that thread earlier whilst rummaging for a solution. I couldn't really understand why Jean's solution worked in that case, or how it could be adapted to help me align things vertically. I tried GUILayout Begin/end Vertical with no luck, but I don't really know how to use them to be honest. Is there anywhere I can find more detailed info on aligning GUI stuff in Playmaker?
« Last Edit: December 17, 2013, 12:29:25 PM by brisck1 »

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: How do you align a GUILayout Text Label?
« Reply #3 on: December 17, 2013, 12:28:21 PM »
Yeah I didn't understand it either. I'll rummage around for an answer. What the Unity Docs provide on the GUI system is basically directly applicable to the playmaker actions.

What I've seen done with gui crosshairs is divide screen size and crosshair image size by 2 and subtracting screen size from image size to get the corner position for the crosshair image. You should be able to do something similar with the gui positions, even with normalized values. What do you think?

http://answers.unity3d.com/questions/33664/how-to-align-a-gui-texture-with-the-top-left-of-th.html
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

brisck1

  • Playmaker Newbie
  • *
  • Posts: 40
Re: How do you align a GUILayout Text Label?
« Reply #4 on: December 17, 2013, 12:48:03 PM »
Yeah I saw that too, but the problem with that approach is that it isn't adaptive to the varying amount of text/subtitles I want to display. For example the text box as it is right now, automatically expands downwards with longer subtitles which is great when it's at the top, but when placing it manually at the bottom i'm presented with two issues: first is that the text expands downwards, below the screen space in some cases, and secondly, GUILayout Begin Area requires that I also set a fixed height for the element, which is also not good as the subtitle text can very greatly and I need it to be adaptive, as it is at the moment.
« Last Edit: December 17, 2013, 12:50:10 PM by brisck1 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do you align a GUILayout Text Label?
« Reply #5 on: December 17, 2013, 01:12:26 PM »
Hi,

 maybe your solution is in creating a custom skin for that text and align the text properly in there, which will allow you to align your text properly as it grows.

bye,

 Jean

brisck1

  • Playmaker Newbie
  • *
  • Posts: 40
Re: How do you align a GUILayout Text Label?
« Reply #6 on: December 17, 2013, 01:33:15 PM »
Hi Jean,

I have already set up a custom skin in order to display the text label in a certain style (see image link in my original post). With it, I customised the font, size, text alignment, etc. but Unity's GUI skins do not have any options for actually aligning the label element on-screen, which is where my problem lies.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do you align a GUILayout Text Label?
« Reply #7 on: December 17, 2013, 02:40:40 PM »
Hi,

 You have to use a combination.

set your skin to alignment to "LowerCenter", and simply use a GUILabel quite simply. Leave the default rect set up ( normalized, 0,0,1,1). Then it will work just fine without any fanzy layouts that anyway would take performances away for nothing...

If you need a working sample, let me know, I have tested the set up above, so I know this works.

bye,

 Jean

brisck1

  • Playmaker Newbie
  • *
  • Posts: 40
Re: How do you align a GUILayout Text Label?
« Reply #8 on: December 17, 2013, 03:27:25 PM »
Hi Jean,

Thanks again for the advice!

I tried your technique, and although it aligns to the bottom, it also seems to make the Text Label box as big as the screen. Not sure if im doing something wrong, check out this screenshot of my setup:

http://i.imgur.com/sjiyNUA.jpg

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do you align a GUILayout Text Label?
« Reply #9 on: December 18, 2013, 03:02:17 AM »
Hi,

 I see, you need some outer to go with it. GUILAyout is the way to go.

Create aLAyout Area of the screen soze, and in there have a vertical layout with a flexible space and then your label, thatw ill have the same effect BUT your label will be fitting its content, not taking up all screen.

 Please find attached a working sample showing both solutions ( simply enable disable the fsms).

Bye,

 Jean

brisck1

  • Playmaker Newbie
  • *
  • Posts: 40
Re: How do you align a GUILayout Text Label?
« Reply #10 on: December 18, 2013, 09:28:21 AM »
Thanks Jean!

I can confirm this works perfectly! Just so I understand what's happening, does "Begin Vertical Area" set things to align elements from the bottom-up?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How do you align a GUILayout Text Label?
« Reply #11 on: December 18, 2013, 09:41:07 AM »
Hi,

 Yep.

bye,

 Jean