void Start() { if (!this._environment) { this._environment = FindObjectOfType <NeodroidEnvironment>(); } var neodroid_environment = this._environment; if (neodroid_environment != null) { this.TryRegister(this._environment_text, neodroid_environment.IdentifierString); this.TryRegister(this._environment_frame, neodroid_environment.FrameString); this.TryRegister(this._environment_obs, neodroid_environment.ObservationsString); this.TryRegister(this._terminated, neodroid_environment.TerminatedBoolean); } if (!this._evaluation_function) { this._evaluation_function = FindObjectOfType <ObjectiveFunction>(); } var evaluation_function = this._evaluation_function; if (evaluation_function != null) { this.TryRegister(this._signal, evaluation_function.SignalString); this.TryRegister(this._episode_length, evaluation_function.EpisodeLengthString); } if (!this._manager) { this._manager = FindObjectOfType <AbstractNeodroidManager>(); } if (this._manager) { if (this._status_text) { this.TryRegister(this._status_text, this._manager.StatusString); } if (this._testing_toggle) { this.TryRegisterProperty(this._testing_toggle.onValueChanged, this._manager.SetTesting); } } if (this._reset_button) { this.TryRegisterVoid(this._reset_button.onClick, this._manager.ResetAllEnvironments); } }
void FindObjects() { this._manager = FindObjectOfType <NeodroidManager>(); this._environments = FindObjectsOfType <NeodroidEnvironment>(); this._actors = FindObjectsOfType <Actor>(); this._actuators = FindObjectsOfType <Actuator>(); this._sensors = FindObjectsOfType <Sensor>(); this._configurables = FindObjectsOfType <Configurable>(); this._objective_functions_function = FindObjectsOfType <ObjectiveFunction>(); this._displayers = FindObjectsOfType <Displayer>(); this._listeners = FindObjectsOfType <Unobservable>(); this._player_reactions = FindObjectOfType <PlayerReactions>(); }
/// <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(); } } }