Tanoda
ActionAdderDropdown.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using System.Linq;
4using UnityEngine;
6using UnityEngine.UI;
7
8[RequireComponent(typeof(Dropdown))]
9public class ActionAdderDropdown : MonoBehaviour
10{
11 public GameObject StageManagerVRContent;
12 public List<UnityEvent> actions;
13 float width;
14 float height;
15 RectTransform rt;
16
17
18 public void onValueChanged(int value)
19 {
20 var dd = GetComponent<Dropdown>();
21 dd.options.Add(new Dropdown.OptionData("temp"));
22 dd.SetValueWithoutNotify(99);
23 dd.options.Reverse();
24 dd.options.RemoveAt(0);
25 dd.options.Reverse();
26 actions[value].Invoke();
27 }
28
29 public void onValueChangedVR(int value)
30 {
31 var dd = GetComponent<Dropdown>();
32 dd.options.Add(new Dropdown.OptionData("temp"));
33 dd.SetValueWithoutNotify(99);
34 dd.options.Reverse();
35 dd.options.RemoveAt(0);
36 dd.options.Reverse();
37 actions[value].Invoke();
38 GameObject go = Controller.Instance.actions.Values.Last().gameObject;
39 go.transform.parent = StageManagerVRContent.transform;
40 go.transform.localScale = Vector3.one;
41 go.transform.localPosition = Vector3.zero;
42 go.AddComponent<PointerInteractable>();
43 go.AddComponent<BoxCollider>();
44 rt = (RectTransform)go.transform;
45 width = rt.rect.width;
46 height = rt.rect.height;
47 go.GetComponent<BoxCollider>().size = new Vector3(width, height, 1);
48 }
49}
void onValueChanged(int value)
void onValueChangedVR(int value)
GameObject StageManagerVRContent
List< UnityEvent > actions
static Controller Instance
Definition: Controller.cs:16