Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
ScriptedReactions.cs
Go to the documentation of this file.
2 using UnityEditor;
3 using UnityEngine;
4 
5 namespace droid.Runtime.InternalReactions {
9  [ExecuteInEditMode]
10  public abstract class ScriptedReactions : MonoBehaviour {
11  #if UNITY_EDITOR
12  const int _script_execution_order = -10000;
13  #endif
14 
17  [SerializeField]
18  bool _debugging;
19 
22  [SerializeField]
24 
27  public static ScriptedReactions Instance { get; private set; }
28 
29  #if NEODROID_DEBUG
30  public bool Debugging { get { return this._debugging; } set { this._debugging = value; } }
33 
34  #endif
35  void Awake() {
38  if (Instance == null) {
39  Instance = this;
40  } else {
41  Debug.LogWarning("WARNING! Multiple PlayerReactions in the scene! Only using " + Instance);
42  }
43 
44  #if UNITY_EDITOR
45  if (!Application.isPlaying) {
46  var manager_script = MonoScript.FromMonoBehaviour(this);
47  if (MonoImporter.GetExecutionOrder(manager_script) != _script_execution_order) {
48  MonoImporter.SetExecutionOrder(manager_script,
49  _script_execution_order); // Ensures that PreStep is called first, before all other scripts.
50  Debug.LogWarning("Execution Order changed, you will need to press play again to make everything function correctly!");
51  EditorApplication.isPlaying = false;
52  //TODO: UnityEngine.Experimental.LowLevel.PlayerLoop.SetPlayerLoop(new UnityEngine.Experimental.LowLevel.PlayerLoopSystem());
53  }
54  }
55  #endif
56  }
57  }
58 }