Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
DataPoller.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using UnityEngine.Events;
3 
4 namespace droid.Runtime.Utilities.GameObjects.StatusDisplayer.EventRecipients {
5  namespace droid.Neodroid.Utilities.Unsorted {
9  public abstract class DataPoller : MonoBehaviour {
10  [SerializeField] UnityEvent _poll_event;
11 
12  [SerializeField] bool _invoke_on_validate = false;
13 
16  public UnityEvent PollEvent { get { return this._poll_event; } set { this._poll_event = value; } }
17 
21  public abstract void PollData(dynamic data);
22 
23  void OnValidate() {
24  if (this._invoke_on_validate) {
25  this._poll_event?.Invoke();
26  }
27  }
28 
29  void OnEnable() { this._poll_event?.Invoke(); }
30 
31  // Update is called once per frame
34  void Update() {
35  if (!this._invoke_on_validate) {
36  this._poll_event?.Invoke();
37  }
38  }
39  }
40  }
41 }