/// <summary> /// </summary> void OnGUI() { var serialised_object = new SerializedObject(this); this._simulation_manager = FindObjectOfType <NeodroidManager>(); if (this._simulation_manager) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUILayout.Label(this._neodroid_icon, GUILayout.Width(_logo_image_size), GUILayout.Height(_logo_image_size)); if (NeodroidEditorUtilities.LinkLabel(new GUIContent(_neodroid_url_text))) { Application.OpenURL(_neodroid_url); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); EditorGUILayout.ObjectField(this._simulation_manager, typeof(AbstractNeodroidManager), true); this._simulation_manager.Configuration = (SimulatorConfiguration) EditorGUILayout.ObjectField((SimulatorConfiguration)this._simulation_manager.Configuration, typeof(SimulatorConfiguration), true); this._simulation_manager.Configuration.FrameSkips = EditorGUILayout.IntField("Frame Skips", this._simulation_manager.Configuration.FrameSkips); this._simulation_manager.Configuration.SimulationType = (SimulationType)EditorGUILayout.EnumPopup("Simulation Type", this._simulation_manager.Configuration.SimulationType); this._player_reactions = FindObjectOfType <PlayerReactions>(); EditorGUILayout.ObjectField(this._player_reactions, typeof(PlayerReactions), true); this._show_detailed_descriptions = EditorGUILayout.Toggle("Show Details", this._show_detailed_descriptions); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); this._environments = NeodroidSceneUtilities.FindAllObjectsOfTypeInScene <PrototypingEnvironment>(); if (this._show_environment_properties.Length != this._environments.Length) { this.Setup(); } this._scroll_position = EditorGUILayout.BeginScrollView(this._scroll_position); EditorGUILayout.BeginVertical("Box"); var num_active_environments = this._environments.Length; var num_inactive_environments = this._environments.Length - num_active_environments; //EditorGUILayout.BeginHorizontal(); GUILayout.Label($"Environments - Active({num_active_environments}), Inactive({num_inactive_environments}), Total({this._environments.Length})"); //EditorGUILayout.EndHorizontal(); if (this._show_environment_properties != null) { for (var i = 0; i < this._show_environment_properties.Length; i++) { if (this._environments[i].isActiveAndEnabled) { this._show_environment_properties[i] = EditorGUILayout.Foldout(this._show_environment_properties[i], $"{this._environments[i].Identifier}"); if (this._show_environment_properties[i]) { var sensors = this._environments[i].Sensors; var configurables = this._environments[i].Configurables; var listeners = this._environments[i].Listeners; var displayers = this._environments[i].Displayers; 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); if (this._show_detailed_descriptions) { this._environments[i].CoordinateSpace = (CoordinateSpace)EditorGUILayout.EnumPopup("Coordinate system", this._environments[i].CoordinateSpace); EditorGUI.BeginDisabledGroup(this._environments[i].CoordinateSpace != CoordinateSpace.Environment_); this._environments[i].CoordinateReferencePoint = (Transform)EditorGUILayout.ObjectField("Reference point", this._environments[i].CoordinateReferencePoint, typeof(Transform), true); EditorGUI.EndDisabledGroup(); if (this._environments[i].ObjectiveFunction != null) { this._environments[i].ObjectiveFunction = (EpisodicObjective)EditorGUILayout.ObjectField("Objective function", (EpisodicObjective)this ._environments[i] .ObjectiveFunction, typeof(EpisodicObjective), true); EditorGUILayout.LabelField("Signal: " + ((EpisodicObjective)this._environments[i].ObjectiveFunction).LastSignal); this._environments[i].ObjectiveFunction.SignalSpace .FromVector3(EditorGUILayout.Vector3Field(Space1.Vector3Description(), this._environments[i].ObjectiveFunction .SignalSpace.ToVector3())); this._environments[i].ObjectiveFunction.EpisodeLength = EditorGUILayout.IntField("Episode Length", this._environments[i].ObjectiveFunction.EpisodeLength); } //EditorGUILayout.BeginHorizontal("Box"); #if NEODROID_DEBUG this._environments[i].Debugging = EditorGUILayout.Toggle("Debugging", this._environments[i].Debugging); #endif //EditorGUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.LabelField("Info:"); EditorGUILayout.Toggle("Terminated", this._environments[i].Terminated); EditorGUI.EndDisabledGroup(); } var s = this._environments[i] as AbstractSpatialPrototypingEnvironment as ActorisedPrototypingEnvironment; if (s) { var actors = s.Actors; this.DrawActors(actors); } else { var c = this._environments[i] as PrototypingEnvironment; if (c) { this.DrawActuators(c.Actuators); } } this.DrawSensors(sensors); this.DrawConfigurables(configurables); this.DrawDisplayers(displayers); this.DrawListeners(listeners); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Disabled environments"); for (var i = 0; i < this._show_environment_properties.Length; i++) { if (!this._environments[i].isActiveAndEnabled) { EditorGUILayout.ObjectField(this._environments[i], typeof(NeodroidEnvironment), true); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); serialised_object.ApplyModifiedProperties(); } } }
void DrawActuators(SortedDictionary <string, IActuator> actuators) { EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Actuators"); foreach (var actuator in actuators) { var actuator_value = (Actuator)actuator.Value; if (actuator_value != null) { EditorGUILayout.BeginVertical("Box"); actuator_value.enabled = EditorGUILayout.BeginToggleGroup(actuator.Key, actuator_value.enabled && actuator_value.gameObject.activeSelf); EditorGUILayout.ObjectField(actuator_value, typeof(Actuator), true); if (this._show_detailed_descriptions) { actuator_value.MotionSpace.FromVector3(EditorGUILayout.Vector3Field(Space1.Vector3Description(), actuator_value .MotionSpace .ToVector3())); //EditorGUILayout.BeginHorizontal("Box"); #if NEODROID_DEBUG actuator_value.Debugging = EditorGUILayout.Toggle("Debugging", actuator_value.Debugging); #endif //EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); }