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 · Nov 28, 2010 at 12:16 PM · guiscrollviewlayout

I need help in making a GUI layout scroll view

if(isinoptions == 8){

var data : HostData[] = MasterServer.PollHostList(); // Go through all the hosts in the host list scrollPos = GUILayout.BeginScrollView (scrollPos, false/alwaysShowHoriz/, true /alwaysShowVert/); //@@ for (var element in data) { var elementPing:Ping=Ping(element.ip.ToString()); var elementPingUIValue:String=elementPing.ToString(); GUILayout.BeginHorizontal();

     GUILayout.Space(20);
     var name = element.gameName + " " + element.connectedPlayers + " / " + element.playerLimit+" Ping:" +elementPingUIValue;
     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";


         Network.Connect(element.ip, element.port);          
     }

     GUILayout.EndScrollView();
     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,240,600,300),connectStatus); GUI.Label(Rect(25,280,600,300),serverFoundStatus); if (GUI.Button (Rect (25,220,100,20), "Refresh List")) { connectStatus="Refreshing Master server list on ip :"+MasterServer.ipAddress; MasterServer.ClearHostList(); MasterServer.RequestHostList("StealthReduxCoop"); } if (GUI.Button (Rect (125,220,50,20), "Back")){ isinoptions=0; }

}

I wanted to make a serverlist and used a scrollview in which i dont have much experience and the result is crashing.What am i doing wrong? Also , how can i make the scrollview have these coordinates (20,20,Screen.width-20,200)

Edit: Oh come on , its been over 2 weeks

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

3 Replies

· Add your reply
  • Sort: 
avatar image
-1
Best Answer

Answer by zmar0519 · Dec 19, 2010 at 01:19 PM

Check out http://unity3d.com/support/documentation/Components/gui-Controls.html Or you might want to try this:

 /* ScrollView example */
 
 var scrollViewVector : Vector2 = Vector2.zero;
 var innerText : String = "I am inside the ScrollView";
 
 function OnGUI () {
     // Begin the ScrollView
     scrollViewVector = GUI.BeginScrollView (Rect (25, 25, 100, 100), scrollViewVector, Rect (0, 0, 400, 400));
 
 // Put something inside the ScrollView
 innerText = GUI.TextArea (Rect (0, 0, 400, 400), innerText);
 
 // End the ScrollView
 GUI.EndScrollView();
Comment
Add comment · Show 1 · 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 YeOldeSnake 1 · Dec 20, 2010 at 01:45 PM 0
Share

since i have no experience in scroll views , can you implement that code in my occasion?

avatar image
2

Answer by carmine · Dec 09, 2012 at 01:46 AM

You're calling "GUILayout.EndScrollView();" inside your for loop. It should be outside.

So it should be more like this...

  • BeginScrollView

  • For loop and whatever you want inside the scrollview

  • EndScrollView

Comment
Add comment · Show 1 · 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 Bunny83 · Dec 09, 2012 at 02:19 AM 0
Share

Well, the question is almost ancient, but you're right ;)

avatar image
0

Answer by ricardo · Mar 03, 2011 at 04:56 PM

hey man. i want to add a button but i cant help me please =(

cheers.

Comment
Add comment · Show 1 · 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 YeOldeSnake 1 · Mar 05, 2011 at 01:59 PM 0
Share

use something like if (GUI.Button (Rect (125,220,50,20), "thees")){ //do my stuff } In the OnGUI function You should ask new questions yourself though and not post your questions as an answer to someone else's question

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

2 People are following this question.

avatar image avatar image

Related Questions

GUILayout beginArea not working with scrollview 1 Answer

Unity GUI fitting item list with max size 0 Answers

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

Add a gui layout into a scroll view 1 Answer

unity scrollview doesnt bounce 0 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