Hello, i am trying to put each key value from dictionary to a scroll view list as buttons, so i tried stuff like Instantiate to spawn buttons, but one thing i don’t get is that how am i going to arrange them using Transform.position in the content of scroll view so they don’t all get in one place and please tell me whether i should use GUI.Button on GUI() or continue with Instantiate or any other method which i dont know about, i hope you understand what i want to say (sorry for my bad English).here is my code so far :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ColorButton : MonoBehaviour {
Dictionary<string, Color32> ColorList = new Dictionary<string, Color32>();
public RectTransform Content_InScrollView;
public GameObject Buttons;
// Use this for initialization
void Start() {
ColorList.Add("LightGreen", new Color32(255, 255, 255, 255)); // Only as Example
ColorList.Add("DarkGreen", new Color32(255, 0, 255, 255)); // Only as Example
foreach (KeyValuePair<string, Color32> colorV in ColorList)
{
Instantiate(); // idk what to do anymore..
}
}
}
(The reason for not putting each button manually in scroll view is that i will be putting more then a hundred buttons).
Any answer could be helpful. Thanks A Lot. (If you have a solution the code can be also in JavaScript i don’t mind i can use them both).