Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
RenderTextureList.cs
Go to the documentation of this file.
1 using System.Collections;
2 using UnityEngine;
3 using UnityEngine.UI;
4 
5 namespace droid.Runtime.Utilities.GameObjects.StatusDisplayer {
9  public class RenderTextureList : MonoBehaviour {
13  public Sprite[] AnimalImages;
14 
18  public GameObject ContentPanel;
19 
23  public GameObject ListItemPrefab;
24 
25  ArrayList _camera_observations;
26 
27  void Start() {
28  // 1. Get the data to be displayed
29  this._camera_observations = new ArrayList {
30  new CameraObservation(this.AnimalImages[0], "A"),
31  new CameraObservation(this.AnimalImages[1], "B"),
32  new CameraObservation(this.AnimalImages[2], "C"),
33  new CameraObservation(this.AnimalImages[3], "D")
34  };
35 
36  if (this.ListItemPrefab) {
37  foreach (CameraObservation animal in this._camera_observations) {
38  var r = Instantiate(this.ListItemPrefab, this.ContentPanel.transform, true);
39  var controller = r.GetComponent<RenderTextureListItem>();
40  controller.Icon.sprite = animal._Icon;
41  controller.Name.text = animal._Name;
42  r.transform.localScale = Vector3.one;
43  }
44  }
45  }
46  }
47 
51  public class RenderTextureListItem : MonoBehaviour {
55  public Image Icon;
56 
60  public Text Name;
61  }
62 
66  public class CameraObservation {
67  public Sprite _Icon;
68  public string _Name;
69 
70  public CameraObservation(Sprite icon, string name) {
71  this._Icon = icon;
72  this._Name = name;
73  }
74  }
75 }