public override void OnInspectorGUI() { GraphOverlay myTarget = (GraphOverlay)target; myTarget.vehicleBody = (Rigidbody)EditorGUILayout.ObjectField("Vehicle", myTarget.vehicleBody, typeof(Rigidbody), true); if (!myTarget.vehicleBody) { return; } myTarget.timeTravel = EditorGUILayout.FloatField("Time travel", myTarget.timeTravel); myTarget.width = EditorGUILayout.Slider("Width", myTarget.width, 0, 1); myTarget.height = EditorGUILayout.Slider("Height", myTarget.height, 0, 1); myTarget.widthSeconds = EditorGUILayout.FloatField("Width seconds", myTarget.widthSeconds); myTarget.heightMeters = EditorGUILayout.FloatField("Height meters", myTarget.heightMeters); myTarget.bgColor = EditorGUILayout.ColorField("Bg color", myTarget.bgColor); myTarget.forwardColor = EditorGUILayout.ColorField("Forward color", myTarget.forwardColor); myTarget.sidewaysColor = EditorGUILayout.ColorField("Sideways color", myTarget.sidewaysColor); myTarget.zeroColor = EditorGUILayout.ColorField("Zero color", myTarget.zeroColor); if (myTarget.vehicleBody) { foreach (var wheelConfig in myTarget.wheelConfigs) { EditorGUILayout.LabelField(wheelConfig.collider.name); wheelConfig.visible = EditorGUILayout.Toggle("Enabled", wheelConfig.visible); } } }
void Start() { // Set up our texture. m_WidthPixels = (int)imageComponent.rectTransform.rect.width; m_HeightPixels = (int)imageComponent.rectTransform.rect.height; m_Texture = new Texture2D(m_WidthPixels, m_HeightPixels); imageComponent.texture = m_Texture; m_Pixels = new Color32[m_WidthPixels * m_HeightPixels]; m_PixelsBg = new Color32[m_WidthPixels * m_HeightPixels]; for (int i = 0; i < m_Pixels.Length; ++i) { m_PixelsBg[i] = backgroundColour; } instance = this; }
// Update is called once per frame void Update() { #if UNITY_EDITOR var activateGameObject = UnityEditor.Selection.activeGameObject; if (activateGameObject) { if (activateGameObject.activeInHierarchy) { var agent = UnityEditor.Selection.activeGameObject.GetComponentInChildren <ProfileController>(); if (agent) { GraphOverlay.Plot("Curvature", agent.curvature); GraphOverlay.Plot("Camber", agent.camber); GraphOverlay.Plot("Inclination", agent.inclination); } } } #endif }
void Update() { #if UNITY_EDITOR var activateGameObject = UnityEditor.Selection.activeGameObject; if (activateGameObject) { if (activateGameObject.activeInHierarchy) { var pathFinder = UnityEditor.Selection.activeGameObject.GetComponentInChildren <ProfileAgent>(); if (pathFinder) { GraphOverlay.Plot("Profile", pathFinder.profile.Select(x => x.speed)); GraphOverlay.Plot("Speed", pathFinder.profile.Select(x => x.actual)); GraphOverlay.Plot("Traction", pathFinder.profile.Select(x => x.traction ? 1f : 0f)); GraphOverlay.Plot("Error", pathFinder.profile.Select(x => x.error)); GraphOverlay.Plot("Drift", pathFinder.profile.Select(x => x.sideslip)); GraphOverlay.Cursor(pathFinder.currentNode); } } } #endif }
private void Update() { if (graph == null) { graph = FindObjectOfType <GraphOverlay>(); } if (graph != null) { if (graph.camera != null) { var texture = graph.camera.targetTexture; if (texture.width != position.width || texture.height != position.height) { texture.Release(); texture = new RenderTexture((int)position.width, (int)position.height, 24); graph.camera.targetTexture = texture; } } Repaint(); } }
private void FixedUpdate() { var activateGameObject = UnityEditor.Selection.activeGameObject; if (activateGameObject) { if (activateGameObject.activeInHierarchy) { var navigator = UnityEditor.Selection.activeGameObject.GetComponent <PathNavigator>(); if (navigator) { if (Curvature.Length != numObservations) { Curvature = new float[numObservations]; Camber = new float[numObservations]; Inclination = new float[numObservations]; Distance = new float[numObservations]; } for (int i = 0; i < numObservations; i++) { var d = navigator.Distance + i * pathInterval; var q = navigator.waypoints.Query(d); Camber[i] = q.Camber; Curvature[i] = q.Curvature; Inclination[i] = q.Inclination; Distance[i] = d; } GraphOverlay.Plot("Curvature", Curvature); GraphOverlay.Plot("Camber", Camber); GraphOverlay.Plot("Inclination", Inclination); } } } }
public static Graph Overlay(this Graph source, GraphOverlay overlay, Action <Node> markNode, Action <Edge> markEdge) { Graph target = new Graph(); foreach (var node in source.Nodes) { var newNode = new Node(node); target.Nodes.Add(newNode); if (overlay.Graph.Nodes.Contains(newNode)) { markNode(newNode); } } foreach (var edge in source.Edges) { var newEdge = new Edge(edge); target.Edges.Add(newEdge); if (overlay.Graph.Edges.Contains(newEdge)) { markEdge(newEdge); } } return(target); }
private void Awake() { imageComponent = GetComponentInChildren <RawImage>(); camera = GetComponentInChildren <Camera>(); instance = null; }