Tanoda
DropDownController.cs
Go to the documentation of this file.
1using NaughtyAttributes;
2using System;
3using System.Collections;
4using System.Collections.Generic;
5using System.Linq;
6using System.Text.RegularExpressions;
7using UnityEngine;
8using UnityEngine.UI;
9
10
11public class DropDownController : MonoBehaviour
12{
13 Dropdown dropdown;
14 //List<GameObject> Items = new List<GameObject>();
15 bool addedComponents = false;
16 public GameObject StageManagerVRContent;
17 int i;
18 string itemName;
19 GameObject go;
20 // Start is called before the first frame update
21 void Start()
22 {
23 dropdown = GetComponent<Dropdown>();
24 }
25
26 void Update()
27 {
28
29 }
30 [Button]
31 public void DropDownClick()
32 {
33 i = 0;
34 dropdown.OnPointerClick(null);
35 if (dropdown.transform.Find("Dropdown List"))
36 {
37 var Items = dropdown.transform.Find("Dropdown List").gameObject.GetComponentsInChildren<Toggle>();
38 foreach (var item in Items)
39 {
40 var data = Regex.Match(item.name, @"\d+");
41 int i = int.Parse(data.Value);
42
43 item.gameObject.AddComponent<BoxCollider>();
44 item.gameObject.GetComponent<BoxCollider>().size = new Vector3(150, 25, 1);
45 item.gameObject.AddComponent<PointerInteractable>();
46 item.gameObject.GetComponent<PointerInteractable>().OnClick.AddListener(() => { GetComponentInParent<ActionAdderDropdown>().onValueChangedVR(i); });
47 }
48 }
49 }
50
51
52}
UnityEngine.UI.Button Button
Definition: Pointer.cs:7
GameObject StageManagerVRContent