protected override void Awake() { base.Awake(); this._manager = FindObjectOfType <NeodroidManager>(); this._camera = this.GetComponent <Camera>(); this._texture = new Texture2D(this._camera.targetTexture.width, this._camera.targetTexture.height); }
void Setup() { var serialised_object = new SerializedObject(this); if (this._simulation_manager == null) { this._simulation_manager = FindObjectOfType <NeodroidManager>(); } serialised_object.ApplyModifiedProperties(); }
void FindObjects() { this._manager = FindObjectOfType <PausableManager>(); this._environments = FindObjectsOfType <NeodroidEnvironment>(); this._actors = FindObjectsOfType <Actor>(); this._motors = FindObjectsOfType <Motor>(); this._observers = FindObjectsOfType <Observer>(); this._configurables = FindObjectsOfType <Configurable>(); this._objective_functions = FindObjectsOfType <ObjectiveFunction>(); this._displayers = FindObjectsOfType <Displayer>(); this._listeners = FindObjectsOfType <EnvironmentListener>(); this._resetables = FindObjectsOfType <Resetable>(); this._player_reactions = FindObjectOfType <PlayerReactions>(); }
void Start() { if (!this._environment) { this._environment = FindObjectOfType <NeodroidEnvironment>(); } if (this._environment) { this.TryRegister(this._environment_text, this._environment.IdentifierString); this.TryRegister(this._environment_frame, this._environment.FrameString); this.TryRegister(this._environment_obs, this._environment.ObservationsString); this.TryRegister(this._terminated, this._environment.TerminatedBoolean); } if (!this._evaluation_function) { this._evaluation_function = FindObjectOfType <ObjectiveFunction>(); } if (this._evaluation_function) { this.TryRegister(this._signal, this._evaluation_function.SignalString); } if (!this._manager) { this._manager = FindObjectOfType <NeodroidManager>(); } 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); } }
protected override void Awake() { base.Awake(); this._manager = FindObjectOfType <NeodroidManager>(); this._camera = this.GetComponent <Camera>(); if (this._camera.targetTexture) { this._texture = new Texture2D(this._camera.targetTexture.width, this._camera.targetTexture.height); if (this._black_white) { this._array = new float[this._texture.width * this._texture.height * 1]; // *1 for clarity } else { this._array = new float[this._texture.width * this._texture.height * 3]; } } else { this._array = new Single[0]; } }
void Start() { this._manager = FindObjectOfType <NeodroidManager> (); }
/// <summary> /// </summary> void OnGUI() { var serialised_object = new SerializedObject(this); this._simulation_manager = FindObjectOfType <PausableManager>(); 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(NeodroidManager), 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.ResetIterations = EditorGUILayout.IntField( "Reset Iterations", this._simulation_manager.Configuration.ResetIterations); this._simulation_manager.Configuration.SimulationType = (SimulationType)EditorGUILayout.EnumPopup( "Simulation Type", this._simulation_manager.Configuration.SimulationType); this._simulation_manager.TestMotors = EditorGUILayout.Toggle( "Test Motors", this._simulation_manager.TestMotors); this._player_reactions = FindObjectOfType <PlayerReactions>(); EditorGUILayout.ObjectField(this._player_reactions, typeof(PlayerReactions), true); 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"); var num_active_environments = this._environments.Length; //TODO: Calculate actual number var num_inactive_environments = this._environments.Length - num_active_environments; //TODO: Calculate actual number GUILayout.Label( $"Environments - Active({num_active_environments}), Inactive({num_inactive_environments}), Total({this._environments.Length})"); 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 actors = this._environments[i].Actors; var observers = this._environments[i].Observers; var configurables = this._environments[i].Configurables; var resetables = this._environments[i].Resetables; 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); this._environments[i].CoordinateSystem = (CoordinateSystem)EditorGUILayout.EnumPopup( "Coordinate system", this._environments[i].CoordinateSystem); EditorGUI.BeginDisabledGroup( this._environments[i].CoordinateSystem != CoordinateSystem.Relative_to_reference_point_); 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", (ObjectiveFunction)this._environments[i].ObjectiveFunction, typeof(ObjectiveFunction), true); this._environments[i].EpisodeLength = EditorGUILayout.IntField( "Episode Length", this._environments[i].EpisodeLength); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.LabelField("Info:"); EditorGUILayout.Toggle("Terminated", this._environments[i].Terminated); EditorGUI.EndDisabledGroup(); this.DrawActors(actors); this.DrawObservers(observers); this.DrawConfigurables(configurables); this.DrawDisplayers(displayers); //this.DrawInternals(resetables, 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(); } } }
/// <summary> /// /// </summary> void OnGUI() { var serialised_object = new SerializedObject(this); this._simulation_manager = FindObjectOfType <PausableManager>(); 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(NeodroidManager), 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.ResetIterations = EditorGUILayout.IntField( "Reset Iterations", this._simulation_manager.Configuration.ResetIterations); this._simulation_manager.Configuration.SimulationType = (SimulationType)EditorGUILayout.EnumPopup( "Simulation Type", this._simulation_manager.Configuration.SimulationType); this._simulation_manager.TestMotors = EditorGUILayout.Toggle( "Test Motors", this._simulation_manager.TestMotors); this._player_reactions = FindObjectOfType <PlayerReactions>(); EditorGUILayout.ObjectField(this._player_reactions, typeof(PlayerReactions), true); 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"); var num_active_environments = this._environments.Length; //TODO: Calculate actual number var num_inactive_environments = this._environments.Length - num_active_environments; //TODO: Calculate actual number GUILayout.Label( $"Environments - Active({num_active_environments}), Inactive({num_inactive_environments}), Total({this._environments.Length})"); 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 actors = this._environments[i].Actors; var observers = this._environments[i].Observers; var configurables = this._environments[i].Configurables; var resetables = this._environments[i].Resetables; 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); this._environments[i].CoordinateSystem = (CoordinateSystem)EditorGUILayout.EnumPopup( "Coordinate system", this._environments[i].CoordinateSystem); EditorGUI.BeginDisabledGroup( this._environments[i].CoordinateSystem != CoordinateSystem.Relative_to_reference_point_); 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", (ObjectiveFunction)this._environments[i].ObjectiveFunction, typeof(ObjectiveFunction), true); this._environments[i].EpisodeLength = EditorGUILayout.IntField( "Episode Length", this._environments[i].EpisodeLength); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.LabelField("Info:"); EditorGUILayout.Toggle("Terminated", this._environments[i].Terminated); EditorGUI.EndDisabledGroup(); EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Actors"); foreach (var actor in actors) { var actor_value = (Actor)actor.Value; if (actor_value != null) { var 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 motors) { var motor_value = (Motor)motor.Value; 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 observers) { var observer_value = (Observer)observer.Value; 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 configurables) { var configurable_value = (Configurable)configurable.Value; 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(Configurable), true); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Displayers"); foreach (var displayer in displayers) { var displayer_value = (Displayer)displayer.Value; if (displayer_value != null) { EditorGUILayout.BeginVertical("Box"); displayer_value.enabled = EditorGUILayout.BeginToggleGroup( displayer.Key, displayer_value.enabled && displayer_value.gameObject.activeSelf); EditorGUILayout.ObjectField(displayer_value, typeof(Displayer), true); EditorGUILayout.EndToggleGroup(); EditorGUILayout.EndVertical(); } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("Box"); /* * GUILayout.Label("Internals"); * foreach (var resetable in resetables) { * var resetable_value = (Resetable) resetable.Value; * 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(); * } * } */ /* * foreach (var listener in listeners) { * if (listener.Value != null) { * EditorGUILayout.BeginVertical("Box"); * listener.Value.enabled = EditorGUILayout.BeginToggleGroup( * listener.Key, * listener.Value.enabled && listener.Value.gameObject.activeSelf); * EditorGUILayout.ObjectField(listener.Value, typeof(EnvironmentListener), true); * EditorGUILayout.EndToggleGroup(); * EditorGUILayout.EndVertical(); * } * } */ EditorGUILayout.EndVertical(); 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(); /* * if (GUILayout.Button("Refresh")) { * this.Refresh(); * } * * EditorGUI.BeginDisabledGroup(!Application.isPlaying); * * if (GUILayout.Button("Step")) { * this._simulation_manager.ReactAndCollectStates( * new Reaction( * new ReactionParameters(true, true, episode_count:true), * null, * null, * null, * null, * "")); * } * * if (GUILayout.Button("Reset")) { * this._simulation_manager.ReactAndCollectStates( * new Reaction( * new ReactionParameters(true, false, true, episode_count:true), * null, * null, * null, * null, * "")); * } * * EditorGUI.EndDisabledGroup(); */ } } }