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 YeOldeSnake 1 · Sep 13, 2010 at 01:55 PM · guiscrollviewlayout

Add a gui layout into a scroll view

if(isinoptions == 8){ var data : HostData[] = MasterServer.PollHostList(); // Go through all the hosts in the host list for (var element in data) { GUILayout.BeginHorizontal(); GUILayout.Space(20); var name = element.gameName + " " + element.connectedPlayers + " / " + element.playerLimit; GUILayout.Label(name); GUILayout.Space(5); var hostInfo; hostInfo = "["; for (var 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.FlexibleSpace(); if (GUILayout.Button("Connect")) { connectStatus="Connecting"; // Set NAT functionality based on the host information Network.useNat=!Network.HavePublicAddress; if (Network.useNat) print("Using Nat punchthrough to connect to host"); else print("Connecting directly to host"); Network.Connect(element.ip, element.port); } GUILayout.EndHorizontal(); } if (data.length>0){ serverFoundStatus=data.length+" Servers Found"; } if (data.length==0){ serverFoundStatus="No public servers found yet"; } GUI.Label(Rect(25,220,300,300),connectStatus); GUI.Label(Rect(25,240,300,300),serverFoundStatus); if (GUI.Button (Rect (25,200,100,20), "Refresh List")) { connectStatus="Refreshing Master server list on ip :"+MasterServer.ipAddress; //MasterServer.ClearHostList(); MasterServer.RequestHostList("StealthReduxCoop");

} if (GUI.Button (Rect (125,200,50,20), "Back")){ isinoptions=0;

} }

i have this code right here , what i want to do is explained in the image below , currently it can get out of the screen if a lot of servers are present

http://img840.imageshack.us/img840/8470/prahblem.png

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 Bampf · Sep 13, 2010 at 05:29 PM

You can wrap the for-loop (that walks the list of servers) with a ScrollView.

Adding a ScrollView to what you already have will probably only require 3 lines of code: a BeginScrollView and an EndScrollView, plus the declaration of the Vector2 that holds the current position scrolled to. Plenty of examples in the docs.

It's going to end up looking something like this. I inserted three new lines (not including comments) marked with "//@@".

// New variable; should go near the top of the file. It belongs to the whole class, // not inside OnGUI(). var scrollPos : Vector2; //@@

function OnGUI() { // .. .. if (isinoptions == 8) { scrollPos = GUILayout.BeginScrollView (scrollPos, false/alwaysShowHoriz/, true /alwaysShowVert/); //@@

     // Go through all the hosts in the host list
     for (var element in data)
     {
         GUILayout.BeginHorizontal();    
         GUILayout.Space(20);
         var name = element.gameName + " " + element.connectedPlayers + " / " + element.playerLimit;
         // .. rest of for-loop code ..
     }

     GUILayout.EndScrollView (); //@@
 if (data.length>0){
     serverFoundStatus=data.length+" Servers Found";
 }
 // etc

There are other options you can pass to BeginScrollView; see the docs for more.

Comment
Add comment · Show 3 · 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 Bampf · Sep 14, 2010 at 01:31 PM 0
Share

Hope this helps, but if this still doesn't address your issue, feel free to clarify with a comment or by adding details to your original question.

avatar image YeOldeSnake 1 · Sep 17, 2010 at 10:40 AM 0
Share

sorry , i was busy throughout the week so i didnt got the chance to respond , i mentioned scrollviews but i do not know much about layout coding so i was asking to learn more about it

avatar image Bampf · Sep 17, 2010 at 01:10 PM 0
Share

I added an (untested) example of what the code might look like.

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

Unity GUI fitting item list with max size 0 Answers

Why is my vertical layout group not spaced correctly? 1 Answer

I need help in making a GUI layout scroll view 3 Answers

GUILayout beginArea not working with scrollview 1 Answer

Chat Window - BeginScrollView - AutoScroll 2 Answers


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