- Home /
How to make a selection list using either GUI system?
How would one go about to make a list of selectable/clickable/interactiable items (pictures, words, anything) using any GUI system (either the legacy system, the new UI system, or through scripting)? I just need to be pointed in the right direction on this problem.
Basically what I am aiming for is a general list that can be scrolled vertically showing a dynamic amount of items that can be interacted by clicking on them. (I was thinking of making buttons scroll within a window or scroll field, but I don't know how well that would go). How would the menu part be made to show this kind of list?
I have a starting point, but have no direction on what to do for making this menu...
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class GalleryMenuScript : MonoBehaviour
{
//Variables
public Vector2 scrollposition;
public string innerText = "Test";
public Vector2 pos = new Vector2(40,60);
public Vector2 size = new Vector2(60,20);
//Aspect ratio variables
public int width = 800;
public int height = 600;
void OnGUI()
{
float x = size.x * Screen.width / width;
float y = size.y * Screen.height / height;
//Start scrollview
scrollposition = GUI.BeginScrollView(new Rect(pos.x, pos.y, x, y), scrollposition, new Rect(pos.x, pos.y, x, y));
//Put something inside the ScrollView
innerText = GUI.TextArea (new Rect (pos.x, pos.y, x, y), innerText);
//End the ScrollView
GUI.EndScrollView();
}
}
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
GUI.Window write elements by pages 0 Answers
Main Menu - One scene or multiple? 1 Answer
Adding Item object to Inventory List 0 Answers
How to place/add a HD image/picture in background of my game? 0 Answers