VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
AVRUI_ClickDragWheelEntryPrefab.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEngine.UI;
5 using UnityEngine.EventSystems;
6 
7 namespace AVR.UI.Utils {
8  public class AVRUI_ClickDragWheelEntryPrefab : MonoBehaviour
9  {
10  private RectTransform rect;
11  private Image img;
12  private Text txt;
13 
14  void Awake() {
15  rect = GetComponent<RectTransform>();
16  img = GetComponentInChildren<Image>();
17  txt = GetComponentInChildren<Text>();
18  }
19 
20  public void markSelected(bool selected) {
21  if(selected) {
22  rect.localScale = new Vector3(1.2f, 1.2f, 1.2f);
23  }
24  else {
25  rect.localScale = new Vector3(1.0f, 1.0f, 1.0f);
26  }
27  }
28 
29  public void initalize(AVRUI_ClickDragWheel.ClickDragWheelEntry entry, float textradius) {
30  img.color = entry.color;
31  txt.text = entry.name;
32 
33  float center_angle = (entry.min_angle + 0.5f * (entry.max_angle - entry.min_angle)) * Mathf.Deg2Rad;
34  Vector2 textPos = textradius * new Vector2(-Mathf.Sin(center_angle), -Mathf.Cos(center_angle));
35  txt.transform.localPosition = new Vector3(textPos.x, textPos.y, 0.0f);
36 
37  img.fillAmount = (entry.max_angle-entry.min_angle) / 360.0f;
38  img.transform.localRotation = Quaternion.AngleAxis(entry.min_angle, Vector3.back);
39  }
40  }
41 }
void initalize(AVRUI_ClickDragWheel.ClickDragWheelEntry entry, float textradius)
RectTransform rect
void markSelected(bool selected)
Text txt
Image img
void Awake()