IMHOTEP Framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
OpacityOfAllChanger.cs
1 using UnityEngine;
2 using System.Collections;
3 using System.Collections.Generic;
4 
5 public class OpacityOfAllChanger : MonoBehaviour {
6 
7  private List<GameObject> organs = new List<GameObject>();
8 
9 
10  void OnEnable () {
11  // Register event callbacks:
12  PatientEventSystem.startListening (PatientEventSystem.Event.PATIENT_FinishedLoading, openPatient);
13  PatientEventSystem.startListening (PatientEventSystem.Event.PATIENT_Closed, closePatient);
14  }
15 
16  void OnDisable () {
17  // Unregister myself:
18  PatientEventSystem.stopListening (PatientEventSystem.Event.PATIENT_FinishedLoading, openPatient);
19  PatientEventSystem.stopListening (PatientEventSystem.Event.PATIENT_Closed, closePatient);
20  }
21 
22  public void addOrgan (GameObject newOrgan) {
23  organs.Add (newOrgan);
24  }
25 
26  public void changeOpacityofAll (float opacity) {
27  foreach(GameObject o in organs) {
28  o.GetComponent<MeshMaterialControl> ().changeOpactiyOfChildren (opacity);
29  }
30  }
31 
32  public void closePatient(object obj = null) {
33  organs = new List<GameObject> ();
34  }
35 
36  public void openPatient(object obj = null) {
37  foreach(Transform child in transform) {
38  if(child.gameObject.GetComponent<MeshMaterialControl>() != null) {
39  organs.Add (child.gameObject);
40  }
41  }
42  }
43 }