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 /
This question was closed May 07, 2014 at 11:01 PM by thornekey for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by thornekey · May 07, 2014 at 01:57 PM · c#guilistviewhorizontal

Clamp/align horizontal view

so basically what i am trying to achieve is a grid like server list. Kind of like "Halo: CE":

alt text

In the Halo server list, the lenght of each part is even and clamped...

This is what I have so far. The problem is that if i make the name of something shorter or longer it pushes all of the other stuff down. Like this: alt text

This is how I want it (I havent achieved the alignment, this one is photoshopped so you understand):

alt text

So, yeah, how would I fix this alignment issue?

(ps: Im using "GUILayout.BeginHorizontal" and such)

Thanks in advance.

how it is.png (28.4 kB)
how it should be.png (28.4 kB)
Comment
Add comment · Show 2
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 Lo0NuhtiK · May 07, 2014 at 02:23 PM 0
Share

http://docs.unity3d.com/Documentation/ScriptReference/GUILayoutOption.html

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

https://docs.unity3d.com/Documentation/Components/class-GUIStyle.html

avatar image thornekey · May 07, 2014 at 02:47 PM 0
Share

ive looked at those, i dont know how to implement them into what i have so far :/

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by robhuhn · May 07, 2014 at 02:57 PM

Your current layout looks like you place all your rows (inner) in one vertical group (outer). That way you will have the same height for all cells in a row but it will adjust the cells in it's width independently.

If you create the vertical groups (inner) first and place these groups in a horizontal group (outer) your cells would have the same width within their column but vary in height. Unfortunately there is no proper grid layout for mixed content afaik.

The Halo lobby seems to have a fixed height anyway so you would be good using the second layout if you want the same- vertical within horizontal.

A simple example (not testet)

 float rowHeight = 50f;

 GUILayout.BeginHorizontal();
 {
     GUILayout.BeginVertical();
     {
         GUILayout.Label("cell 0:0 - Long text should expand other cells within this col", GUILayout.Height(rowHeight));
         GUILayout.Label("cell 0:1", GUILayout.Height(rowHeight));
     }
     GUILayout.EndVertical();
     GUILayout.FlexibleSpace(); //take as much space as possible between the cols
     GUILayout.BeginVertical();
     {
         GUILayout.Label("cell 1:0", GUILayout.Height(rowHeight));
         GUILayout.Label("cell 1:1", GUILayout.Height(rowHeight));
     }
     GUILayout.EndVertical();
     GUILayout.FlexibleSpace();
     GUILayout.BeginVertical();
     {
         GUILayout.Button("cell 2:0", GUILayout.Height(rowHeight));
         GUILayout.Button("cell 2:1", GUILayout.Height(rowHeight));
     }
     GUILayout.EndVertical();
 }
 GUILayout.EndHorizontal();

You could also find the highest cell dynamically and adjust other cells.

Comment
Add comment · Show 6 · 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 thornekey · May 07, 2014 at 03:06 PM 0
Share

Hmm, this seems like it could work. Ill show you what I originally had:

                 GUILayout.BeginVertical();
                 GUILayout.Space(64);
                 scrollPos = GUILayout.BeginScrollView(scrollPos, false, true, GUILayout.Width(916), GUILayout.Height(430));
                 GUILayout.Space(32);
                 GUILayout.BeginHorizontal("",  GUILayout.Width(Screen.width - 96), GUILayout.Height(32));
                 GUILayout.Space(64);
                 string info = element.gameName;
                 GUILayout.Label(info);
                 GUILayout.Space(5);
                 string hostInfo;
                 hostInfo = "[ ";
                 foreach (string host in element.ip)
                     hostInfo = hostInfo + host + ":" + element.port + " ";
                     hostInfo = hostInfo + "]";
                     GUILayout.Label(hostInfo);
                     GUILayout.Space(5);
                     GUILayout.Label(element.comment);
                     GUILayout.Space(5);
                     GUILayout.Label(element.connectedPlayers.ToString() + " // " + element.playerLimit.ToString());
                     GUILayout.Space(10);
                     
                     if (masterPing.isDone) {
                         if (masterPing.time >= 0) {
                         GUILayout.Label(masterPing.time + " ms");
                         }
                         else if (masterPing.time < 0) {
                         GUILayout.Label("0 ms");
                         }
                     }
                     else {
                         GUILayout.Label("0 ms");
                     }
                 
                     GUILayout.Space(10);
                     GUILayout.FlexibleSpace();
                     if (GUILayout.Button("Join Server", GUILayout.Width(128), GUILayout.Height(32))) {
                         PlayerPrefs.SetString("Player_Name", playerName);
                         Network.Connect(element);
                         menu_WWconnect = false;
 
                     }    
             GUILayout.Space(32);
 
             GUILayout.EndHorizontal();
             GUILayout.EndScrollView();
 
             GUILayout.EndVertical();
             }
         
avatar image robhuhn · May 07, 2014 at 03:17 PM 0
Share

Yes, there you have the BeginHorizontal within BeginVertical. I guess the other way around would rather fit your needs.

avatar image thornekey · May 07, 2014 at 03:22 PM 0
Share

ok thanks ill try and get back to u! :D

avatar image thornekey · May 07, 2014 at 03:38 PM 0
Share

it did this:

alt text

picture 10.png (20.2 kB)
avatar image thornekey · May 07, 2014 at 10:55 PM 0
Share

ok ive fixed it a bit. Now ive got it to this:

alt text

picture 13.png (24.6 kB)
Show more comments
avatar image
0

Answer by Kacheek · May 07, 2014 at 02:23 PM

use GUI instead of GUILayout ;)

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

Follow this Question

Answers Answers and Comments

23 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Method is called, but GUI doesn't show up 1 Answer

C# List and GUI 3 Answers

How to add a reorderable list on CUSTOM EDITOR WINDOW? 0 Answers

C# how to create a Descending GUI List 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