コード例 #1
0
        /// <summary>
        /// Method called when another scenario element has been selected
        /// </summary>
        /// <param name="previousElement">Scenario element that has been deselected</param>
        /// <param name="selectedElement">Scenario element that has been selected</param>
        private void OnSelectedOtherElement(ScenarioElement previousElement, ScenarioElement selectedElement)
        {
            if (agentWaypointsPath != null)
            {
                agentWaypointsPath.IsActiveChanged -= AgentWaypointsPathOnIsActiveChanged;
            }

            selectedAgent = selectedElement as ScenarioAgent;
            //Attach to selected agent events
            if (selectedAgent != null)
            {
                agentWaypointsPath = selectedAgent.GetExtension <AgentWaypointsPath>();
                if (agentWaypointsPath == null)
                {
                    Hide();
                }
                else
                {
                    agentWaypointsPath.IsActiveChanged += AgentWaypointsPathOnIsActiveChanged;
                    Show();
                }
            }
            else
            {
                Hide();
            }
        }
コード例 #2
0
        /// <summary>
        /// Method called when another scenario element has been selected
        /// </summary>
        /// <param name="previousElement">Scenario element that has been deselected</param>
        /// <param name="selectedElement">Scenario element that has been selected</param>
        private void OnSelectedOtherElement(ScenarioElement previousElement, ScenarioElement selectedElement)
        {
            if (isAddingWaypoints)
            {
                ScenarioManager.Instance.GetExtension <InputManager>().CancelAddingElements(this);
            }

            //Force input apply on deselect
            if (selectedWaypoint != null)
            {
                SubmitChangedInputs();
            }
            selectedWaypoint           = selectedElement as ScenarioAgentWaypoint;
            selectedAgent              = selectedWaypoint != null ? (ScenarioAgent)selectedWaypoint.ParentElement : null;
            selectedAgentWaypointsPath =
                selectedAgent == null ? null : selectedAgent.GetExtension <AgentWaypointsPath>();
            //Disable waypoints for ego vehicles
            if (selectedAgent == null || selectedAgentWaypointsPath == null ||
                !selectedAgent.Source.AgentSupportWaypoints(selectedAgent))
            {
                gameObject.SetActive(false);
            }
            else
            {
                gameObject.SetActive(true);
                speedPanel.SetActive(selectedWaypoint != null);
                accelerationPanel.SetActive(selectedWaypoint != null);
                waitTimePanel.SetActive(selectedWaypoint != null);
                if (selectedWaypoint != null)
                {
                    speedInput.CurrentContext = selectedWaypoint;
                    speedInput.ExternalValueChange(selectedWaypoint.DestinationSpeed, selectedWaypoint, false);
                    accelerationInput.CurrentContext = selectedWaypoint;
                    accelerationInput.ExternalValueChange(selectedWaypoint.Acceleration, selectedWaypoint, false);
                    waitTimeInput.text = selectedWaypoint.WaitTime.ToString("F");
                }

                triggerEditPanel.OnSelectedNewTrigger(selectedWaypoint.LinkedTrigger);
                UnityUtilities.LayoutRebuild(transform as RectTransform);
            }
        }