UnityMol  0.9.6-875
UnityMol viewer / In developement
GUILinker.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Collections;
3 using UnityEngine.UI;
4 
5 public class GUILinker : MonoBehaviour {
6 
7  private Toggle toggle;
8  private InputField inputField;
9  private Slider slider;
10 
11  public void Awake() {
12  toggle = GetComponent<Toggle>();
13  inputField = GetComponent<InputField>();
14  slider = GetComponent<Slider>();
15  }
16 
17  public void SetBool(ref bool boolToSet) {
18  if (toggle != null) {
19  boolToSet = toggle.isOn;
20  Debug.Log ("State change to " + boolToSet);
21  }
22  }
23 
24  public void SetString(ref string textToSet) {
25  if (inputField != null) {
26  textToSet = inputField.text;
27  Debug.Log ("State change to " + textToSet);
28  }
29  }
30 
31  public void SetFloat(ref float floatToSet) {
32  if (slider != null) {
33  floatToSet = slider.value;
34  Debug.Log ("State change to " + floatToSet);
35  }
36  }
37 
38 // public void AddSetBool(ref bool boolToSet){
39 // toggle.onValueChanged.AddListener ((vbool)=>SetBool(ref boolToSet));
40 // }
41 }
Toggle toggle
Definition: GUILinker.cs:7
void SetString(ref string textToSet)
Definition: GUILinker.cs:24
void Awake()
Definition: GUILinker.cs:11
Slider slider
Definition: GUILinker.cs:9
void SetBool(ref bool boolToSet)
Definition: GUILinker.cs:17
InputField inputField
Definition: GUILinker.cs:8
void SetFloat(ref float floatToSet)
Definition: GUILinker.cs:31