void Setup() { var serialised_object = new SerializedObject(this); this._simulation_manager = FindObjectOfType <PausableManager>(); serialised_object.ApplyModifiedProperties(); }
// Use this for initialization void Start() { if (!this._time_simulation_manager) { this._time_simulation_manager = FindObjectOfType <PausableManager>(); } this._status_text = this.GetComponent <Text>(); }
void OnEnable() { this._time_simulation_manager = FindObjectOfType <PausableManager>(); this._environments = FindObjectsOfType <PrototypingEnvironment>(); this._actors = FindObjectsOfType <Actor>(); this._motors = FindObjectsOfType <Motor>(); this._observers = FindObjectsOfType <Observer>(); this._configurables = FindObjectsOfType <ConfigurableGameObject>(); this._objective_functions = FindObjectsOfType <ObjectiveFunction>(); this._icon = (Texture2D)AssetDatabase.LoadAssetAtPath( "Assets/Neodroid/Icons/information.png", typeof(Texture2D)); this.titleContent = new GUIContent("Neo:Debug", this._icon, "Window for controlling debug messages"); }
void OnGUI() { this._time_simulation_manager = FindObjectOfType <PausableManager>(); this._environments = FindObjectsOfType <PrototypingEnvironment>(); this._actors = FindObjectsOfType <Actor>(); this._motors = FindObjectsOfType <Motor>(); this._observers = FindObjectsOfType <Observer>(); this._configurables = FindObjectsOfType <ConfigurableGameObject>(); this._objective_functions = FindObjectsOfType <ObjectiveFunction>(); this._show_simulation_manager_debug = EditorGUILayout.Toggle( "Debug simulation manager", this._show_simulation_manager_debug); this._show_environments_debug = EditorGUILayout.Toggle( "Debug all environments", this._show_environments_debug); this._show_actors_debug = EditorGUILayout.Toggle("Debug all actors", this._show_actors_debug); this._show_motors_debug = EditorGUILayout.Toggle("Debug all motors", this._show_motors_debug); this._show_observers_debug = EditorGUILayout.Toggle("Debug all observers", this._show_observers_debug); this._show_configurables_debug = EditorGUILayout.Toggle( "Debug all configurables", this._show_configurables_debug); this._show_objective_functions_debug = EditorGUILayout.Toggle( "Debug all objective functions", this._show_objective_functions_debug); if (GUILayout.Button("Apply")) { if (this._time_simulation_manager != null) { this._time_simulation_manager.Debugging = this._show_simulation_manager_debug; } foreach (var environment in this._environments) { environment.Debugging = this._show_environments_debug; } foreach (var actor in this._actors) { actor.Debugging = this._show_actors_debug; } foreach (var motor in this._motors) { motor.Debugging = this._show_motors_debug; } foreach (var observer in this._observers) { observer.Debugging = this._show_observers_debug; } foreach (var configurable in this._configurables) { configurable.Debugging = this._show_configurables_debug; } foreach (var objective_functions in this._objective_functions) { objective_functions.Debugging = this._show_objective_functions_debug; } } /*if (GUI.changed) { * EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); * // Unity not tracking changes to properties of gameobject made through this window automatically and * // are not saved unless other changes are made from a working inpector window * }*/ }
void OnGUI() { var serialised_object = new SerializedObject(this); this._time_simulation_manager = FindObjectOfType <PausableManager>(); if (this._time_simulation_manager) { EditorGUILayout.BeginHorizontal(); GUILayout.Label( this._neodroid_icon, GUILayout.Width(this._preview_image_size), GUILayout.Height(this._preview_image_size)); EditorGUILayout.BeginVertical(); this._time_simulation_manager.Configuration.FrameSkips = EditorGUILayout.IntField( "Frame Skips", this._time_simulation_manager.Configuration.FrameSkips); this._time_simulation_manager.Configuration.ResetIterations = EditorGUILayout.IntField( "Reset Iterations", this._time_simulation_manager.Configuration.ResetIterations); this._time_simulation_manager.Configuration.SimulationType = (SimulationType)EditorGUILayout.EnumPopup( "Simulation Type", this._time_simulation_manager.Configuration.SimulationType); this._time_simulation_manager.TestMotors = EditorGUILayout.Toggle( "Test Motors", this._time_simulation_manager.TestMotors); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); this._environments = NeodroidUtilities.FindAllObjectsOfTypeInScene <PrototypingEnvironment>(); if (this._show_environment_properties.Length != this._environments.Length) { this.Setup(); } this._scroll_position = EditorGUILayout.BeginScrollView(this._scroll_position); EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Environments"); if (this._show_environment_properties != null) { for (var i = 0; i < this._show_environment_properties.Length; i++) { this._show_environment_properties[i] = EditorGUILayout.Foldout( this._show_environment_properties[i], this._environments[i].Identifier); if (this._show_environment_properties[i]) { this._actors = this._environments[i].Actors; this._observers = this._environments[i].Observers; this._configurables = this._environments[i].Configurables; this._resetables = this._environments[i].Resetables; EditorGUILayout.BeginVertical("Box"); this._environments[i].enabled = EditorGUILayout.BeginToggleGroup( this._environments[i].Identifier, this._environments[i].enabled && this._environments[i].gameObject.activeSelf); EditorGUILayout.ObjectField(this._environments[i], typeof(PrototypingEnvironment), true); this._environments[i].CoordinateSystem = (CoordinateSystem)EditorGUILayout.EnumPopup( "Coordinate system", this._environments[i].CoordinateSystem); EditorGUI.BeginDisabledGroup( this._environments[i].CoordinateSystem != CoordinateSystem.RelativeToReferencePoint); this._environments[i].CoordinateReferencePoint = (Transform)EditorGUILayout.ObjectField( "Reference point", this._environments[i].CoordinateReferencePoint, typeof(Transform), true); EditorGUI.EndDisabledGroup(); this._environments[i].ObjectiveFunction = (ObjectiveFunction)EditorGUILayout.ObjectField( "Objective function", this._environments[i].ObjectiveFunction, typeof(ObjectiveFunction), true); this._environments[i].EpisodeLength = EditorGUILayout.IntField( "Episode Length", this._environments[i].EpisodeLength); EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Actors"); foreach (var actor in this._actors) { if (actor.Value != null) { this._motors = actor.Value.Motors; EditorGUILayout.BeginVertical("Box"); actor.Value.enabled = EditorGUILayout.BeginToggleGroup( actor.Key, actor.Value.enabled && actor.Value.gameObject.activeSelf); EditorGUILayout.ObjectField(actor.Value, typeof(Actor), true); EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Motors"); foreach (var motor in this._motors) { if (motor.Value != null) { EditorGUILayout.BeginVertical("Box"); motor.Value.enabled = EditorGUILayout.BeginToggleGroup( motor.Key, motor.Value.enabled && motor.Value.gameObject.activeSelf); EditorGUILayout.ObjectField(motor.Value, typeof(Motor), true); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Observers"); foreach (var observer in this._observers) { if (observer.Value != null) { EditorGUILayout.BeginVertical("Box"); observer.Value.enabled = EditorGUILayout.BeginToggleGroup( observer.Key, observer.Value.enabled && observer.Value.gameObject.activeSelf); EditorGUILayout.ObjectField(observer.Value, typeof(Observer), true); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Configurables"); foreach (var configurable in this._configurables) { if (configurable.Value != null) { EditorGUILayout.BeginVertical("Box"); configurable.Value.enabled = EditorGUILayout.BeginToggleGroup( configurable.Key, configurable.Value.enabled && configurable.Value.gameObject.activeSelf); EditorGUILayout.ObjectField(configurable.Value, typeof(ConfigurableGameObject), true); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Resetables"); foreach (var resetable in this._resetables) { if (resetable.Value != null) { EditorGUILayout.BeginVertical("Box"); resetable.Value.enabled = EditorGUILayout.BeginToggleGroup( resetable.Key, resetable.Value.enabled && resetable.Value.gameObject.activeSelf); EditorGUILayout.ObjectField(resetable.Value, typeof(Resetable), true); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); serialised_object.ApplyModifiedProperties(); if (GUILayout.Button("Refresh")) { this.Refresh(); } EditorGUI.BeginDisabledGroup(!Application.isPlaying); if (GUILayout.Button("Step")) { this._time_simulation_manager.React( new Reaction(new ReactionParameters(true, true, false, false, false), null, null, null)); } if (GUILayout.Button("Reset")) { this._time_simulation_manager.React( new Reaction(new ReactionParameters(true, false, true, false, false), null, null, null)); } EditorGUI.EndDisabledGroup(); } } }