Browse Source

Finished RouteEditor and RouteManager

Marcel Zickler 3 years ago
parent
commit
af9a8b5c7c

+ 1 - 0
.idea/.idea.VR Cycling/.idea/indexLayout.xml

@@ -33,6 +33,7 @@
       <Path>Integrations</Path>
       <Path>Library</Path>
       <Path>Logs</Path>
+      <Path>Temp</Path>
       <Path>UserSettings</Path>
       <Path>obj</Path>
     </explicitExcludes>

+ 1 - 2
Assembly-CSharp-Editor.csproj

@@ -62,8 +62,7 @@
      <Compile Include="Assets\Editor\CustomWheelColliderEditor.cs" />
      <Compile Include="Assets\Editor\FrontWheelTrackerEditor.cs" />
      <Compile Include="Assets\Editor\KineticLegTrackerEditor.cs" />
-     <Compile Include="Assets\Editor\RouteDrawer.cs" />
-     <Compile Include="Assets\Editor\RoutesEditor.cs" />
+     <Compile Include="Assets\Editor\RouteEditor.cs" />
      <Compile Include="Assets\TutorialInfo\Scripts\Editor\ReadmeEditor.cs" />
  <Reference Include="UnityEditor.TestRunner">
  <HintPath>C:/Unity Projects/VR Cycling/Library/ScriptAssemblies/UnityEditor.TestRunner.dll</HintPath>

+ 1 - 1
Assembly-CSharp.csproj

@@ -293,7 +293,7 @@
      <Compile Include="Assets\Scripts\Roads\CrossingExtras.cs" />
      <Compile Include="Assets\Scripts\Roads\StraightRoadExtras.cs" />
      <Compile Include="Assets\Scripts\Routes\Route.cs" />
-     <Compile Include="Assets\Scripts\Routes\Routes.cs" />
+     <Compile Include="Assets\Scripts\Routes\RouteManager.cs" />
      <Compile Include="Assets\Scripts\Routes\Turn.cs" />
      <Compile Include="Assets\Scripts\Sensors\ANT\HrReceiver.cs" />
      <Compile Include="Assets\Scripts\Sensors\ANT\PowerMeterReceiver.cs" />

+ 0 - 50
Assets/Editor/RouteDrawer.cs

@@ -1,50 +0,0 @@
-using Routes;
-using UnityEditor;
-using UnityEngine;
-using UnityEngine.UIElements;
-
-
-// ReSharper disable once CheckNamespace
-public static class RouteDrawer
-{
-
-    private static bool showListContent = true;
-
-    public static void PropertyField(SerializedProperty route) //TODO: onDelete
-    {
-        Debug.Log("route = "+route);
-        ListField(route.FindPropertyRelative("items"));
-    }
-
-    private static void ListField(SerializedProperty list)
-    {
-        EditorGUILayout.BeginHorizontal();
-        showListContent = EditorGUILayout.Foldout(showListContent, $"{list.displayName} (Length = {0/*list.arraySize*/})");
-        if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(32)))
-        {
-            //list.DeleteArrayElementAtIndex(i); TODO: onDelete
-        }
-        EditorGUILayout.EndHorizontal();
-        //EditorGUILayout.PropertyField(list.displayName);
-        if (showListContent) {
-            EditorGUI.indentLevel += 1;
-            for (var i = 0; i < list.arraySize; i++) {
-                EditorGUILayout.BeginHorizontal();
-                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
-                if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(32)))
-                {
-                    list.DeleteArrayElementAtIndex(i);
-                }
-                EditorGUILayout.EndHorizontal();
-            }
-            EditorGUI.indentLevel -= 1;
-        }
-        
-        //EditorGUILayout.EndHorizontal();
-        //EditorGUILayout.EndFoldoutHeaderGroup();
-        /*if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(128)))
-        {
-            list.InsertArrayElementAtIndex(0);
-        }*/
-    }
-}

+ 0 - 3
Assets/Editor/RouteDrawer.cs.meta

@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: 48e00bf4fa1a4e67a27024f65c13ed6f
-timeCreated: 1609612095

+ 234 - 0
Assets/Editor/RouteEditor.cs

@@ -0,0 +1,234 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Runtime.InteropServices;
+using ICSharpCode.NRefactory.PrettyPrinter;
+using Roads;
+using Routes;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.Rendering;
+using UnityEngine.Rendering.UI;
+
+
+[CustomEditor(typeof(Route))]
+[CanEditMultipleObjects]
+// ReSharper disable once CheckNamespace
+public class RoutesEditor : Editor
+{
+    private bool showListContent;
+    private bool inSelectionMode;
+    private SceneView sceneView;
+    private readonly List<Turn> selectedTurns = new List<Turn>();
+
+    private static readonly Dictionary<RoadDirection, int> roadDirectionIndexes = new Dictionary<RoadDirection, int>
+    {
+        {RoadDirection.West, 0},
+        {RoadDirection.North, 1},
+        {RoadDirection.East, 2},
+        {RoadDirection.South, 3},
+        {RoadDirection.None, 4}
+    };
+
+    public override void OnInspectorGUI()
+    {
+        serializedObject.Update();
+        RoutesList(serializedObject.FindProperty("items"));
+        //EditorGUILayout.PropertyField(routes.FindPropertyRelative("arraySize"), true);true);
+        serializedObject.ApplyModifiedProperties();
+    }
+
+    private void OnSceneGUI()
+    {
+        if (inSelectionMode)
+        {
+            if (Event.current.type == EventType.Layout)
+            {
+                HandleUtility.AddDefaultControl(0);
+            }
+
+            sceneView = SceneView.currentDrawingSceneView;
+            if (sceneView == null)
+            {
+                Debug.LogError("RouteEditor: No Scene View found");
+            }
+
+            if (sceneView != null && Event.current.type == EventType.MouseDown && Event.current.button == 0)
+            {
+                /*var coords = Event.current.mousePosition;
+                var pos = sceneView.camera.ScreenToWorldPoint(new Vector3(coords.x, coords.y, sceneView.camera.nearClipPlane));
+                Debug.Log("pos: "+pos);
+                Debug.DrawRay(pos, Vector3.down * 1000, Color.magenta);*/
+                Ray worldRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
+                RaycastHit hitInfo;
+
+                if (Physics.Raycast(worldRay, out hitInfo))
+                {
+                    var intersection = GetIntersection(hitInfo.collider.gameObject);
+                    selectedTurns.Add(intersection);
+                }
+            }
+        }
+
+        if (GUI.changed)
+            EditorUtility.SetDirty(target);
+    }
+
+    private Turn GetIntersection(GameObject gameObject)
+    {
+        Turn turn = null;
+        for (var i = 0; i < 3; i++)
+        {
+            turn = gameObject.GetComponent<Turn>();
+            if (turn != null || gameObject.transform.parent == null) break;
+            gameObject = gameObject.transform.parent.gameObject;
+        }
+
+        Debug.Log($"Intersected Turn: {turn}");
+        return turn;
+    }
+
+    private void RoutesList(SerializedProperty list)
+    {
+        showListContent =
+            EditorGUILayout.BeginFoldoutHeaderGroup(showListContent, $"{list.displayName} (Length = {list.arraySize})");
+
+        if (showListContent)
+        {
+            EditorGUI.indentLevel += 1;
+            EditorGUILayout.BeginHorizontal();
+            EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
+            if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(32)))
+            {
+                list.InsertArrayElementAtIndex(list.arraySize);
+            }
+
+            if (GUILayout.Button(!inSelectionMode ? "Selection Mode" : "Quit Selection Mode", GUILayout.Width(128)))
+            {
+                SwitchSelectionMode();
+            }
+
+            if (GUILayout.Button("Clear", GUILayout.Width(56)))
+            {
+                Clear();
+            }
+
+            GUILayout.FlexibleSpace();
+            EditorGUILayout.EndHorizontal();
+            for (var i = 0; i < list.arraySize; i++)
+            {
+                EditorGUILayout.BeginHorizontal();
+                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), true);
+                if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.Width(32)))
+                {
+                    list.DeleteArrayElementAtIndex(i);
+                }
+
+                EditorGUILayout.EndHorizontal();
+            }
+
+            EditorGUI.indentLevel -= 1;
+        }
+
+        EditorGUILayout.EndFoldoutHeaderGroup();
+    }
+
+    private void Clear()
+    {
+        throw new NotImplementedException();
+    }
+
+    private void SwitchSelectionMode()
+    {
+        inSelectionMode = !inSelectionMode;
+        if (inSelectionMode)
+        {
+            selectedTurns.Clear();
+        }
+        else
+        {
+            ApplySelectedTurns();
+        }
+    }
+
+    private void ApplySelectedTurns()
+    {
+        var items = serializedObject.FindProperty("items");
+        var size = items.arraySize;
+        SerializedProperty previousItem = null;
+
+        for (var index = 0; index < selectedTurns.Count; index++)
+        {
+            var serializedIndex = size + index;
+            var turn = selectedTurns[index];
+            var previousTurn = index == 0 ? null : selectedTurns[index - 1];
+            items.InsertArrayElementAtIndex(serializedIndex);
+
+            var newItem = items.GetArrayElementAtIndex(serializedIndex);
+            newItem.FindPropertyRelative("turn").objectReferenceValue = turn;
+            Debug.Log($"---- Element {serializedIndex} ----");
+            Debug.Log("Calculate From");
+            newItem.FindPropertyRelative("from").enumValueIndex = CalculateDirection(turn.transform,
+                previousTurn != null ? previousTurn.transform : null);
+            newItem.FindPropertyRelative("to").enumValueIndex = roadDirectionIndexes[RoadDirection.None];
+
+            if (previousItem != null)
+            {
+                Debug.Log("Calculate Previous To");
+                previousItem.FindPropertyRelative("to").enumValueIndex =
+                    CalculateDirection(previousTurn != null ? previousTurn.transform : null, turn.transform);
+            }
+
+            previousItem = newItem;
+        }
+
+        selectedTurns.Clear();
+    }
+
+    private int CalculateDirection(Transform turnTransform, Transform reference)
+    {
+        if (reference == null) return roadDirectionIndexes[RoadDirection.None];
+        var dif = reference.position - turnTransform.position;
+        Debug.Log("Difference to reference = " + dif);
+
+        RoadDirection direction;
+        if (Mathf.Abs(dif.x) > Mathf.Abs(dif.z))
+        {
+            direction = dif.x < 0 ? RoadDirection.West : RoadDirection.East;
+        }
+        else
+        {
+            direction = dif.z < 0 ? RoadDirection.South : RoadDirection.North;
+        }
+
+        return roadDirectionIndexes[direction];
+    }
+    
+    
+
+    [DrawGizmo(GizmoType.Selected)]
+    private static void DrawRoutePreview(Route route, GizmoType gizmoType)
+    {
+        if (route.items == null) return;
+        Gizmos.color = Color.red;
+        Turn previousTurn = null;
+        foreach (var item in route.items)
+        {
+            var turn = item.turn;
+
+            if (previousTurn != null)
+            {
+                //Gizmos.DrawCube(previousTurn.transform.position + turn.transform.position /2f, turn.transform.position - previousTurn.transform.position + Vector3.one * 0.1f);
+                //Gizmos.DrawLine(previousTurn.transform.position, turn.transform.position);
+                //var p1 = previousTurn.transform.position;
+                //var p2 = turn.transform.position;
+                //var thickness = 3;
+                //Handles.DrawBezier(p1,p2,p1,p2, Color.red,null,thickness);
+                Helpers.DrawLine(previousTurn.transform.position, turn.transform.position, 3);
+            }
+            
+            previousTurn = turn;
+        }
+
+    }
+}

+ 0 - 0
Assets/Editor/RoutesEditor.cs.meta → Assets/Editor/RouteEditor.cs.meta


+ 0 - 38
Assets/Editor/RoutesEditor.cs

@@ -1,38 +0,0 @@
-using UnityEditor;
-using UnityEngine;
-
-
-[CustomEditor(typeof(Routes.Routes))]
-[CanEditMultipleObjects]
-// ReSharper disable once CheckNamespace
-public class RoutesEditor : Editor
-{
-    private bool showListContent;
-    
-    public override void OnInspectorGUI()
-    {
-        serializedObject.Update();
-        RoutesList(serializedObject.FindProperty("routes"));
-        //EditorGUILayout.PropertyField(routes.FindPropertyRelative("arraySize"), true);
-        EditorGUILayout.Space();
-        EditorGUILayout.PropertyField(serializedObject.FindProperty("selectedRoute"), true);
-        serializedObject.ApplyModifiedProperties();
-    }
-
-    private void RoutesList(SerializedProperty list)
-    {
-        showListContent = EditorGUILayout.BeginFoldoutHeaderGroup(showListContent, $"{list.displayName} (Length = {list.arraySize})");
-        if (showListContent)
-        {
-            EditorGUI.indentLevel += 1;
-            EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
-            for (var i = 0; i < list.arraySize; i++) {
-                RouteDrawer.PropertyField(list.GetArrayElementAtIndex(i));
-            }
-            EditorGUI.indentLevel -= 1;
-        }
-        
-        EditorGUILayout.EndFoldoutHeaderGroup();
-        
-    }
-}

+ 31 - 0
Assets/Scripts/Helpers.cs

@@ -26,4 +26,35 @@ public class Helpers
         Debug.DrawLine(corner3, corner0, Color.green);
         Debug.DrawRay(position, normal, Color.red);
     }
+    
+    public static void DrawLine(Vector3 p1, Vector3 p2, float width)
+    {
+        int count = 1 + Mathf.CeilToInt(width); // how many lines are needed.
+        if (count == 1)
+        {
+            Gizmos.DrawLine(p1, p2);
+        }
+        else
+        {
+            Camera c = Camera.current;
+            if (c == null)
+            {
+                Debug.LogError("Camera.current is null");
+                return;
+            }
+            var scp1 = c.WorldToScreenPoint(p1);
+            var scp2 = c.WorldToScreenPoint(p2);
+ 
+            Vector3 v1 = (scp2 - scp1).normalized; // line direction
+            Vector3 n = Vector3.Cross(v1, Vector3.forward); // normal vector
+ 
+            for (int i = 0; i < count; i++)
+            {
+                Vector3 o = 0.99f * n * width * ((float)i / (count - 1) - 0.5f);
+                Vector3 origin = c.ScreenToWorldPoint(scp1 + o);
+                Vector3 destiny = c.ScreenToWorldPoint(scp2 + o);
+                Gizmos.DrawLine(origin, destiny);
+            }
+        }
+    }
 }

+ 0 - 1
Assets/Scripts/Pools/Pool.cs

@@ -15,7 +15,6 @@ namespace Pools
         private Queue<GameObject> inactive;
         private HashSet<GameObject> active;
 
-
         private void Awake()
         {
             active = new HashSet<GameObject>();

+ 5 - 95
Assets/Scripts/Roads/CrossingExtras.cs

@@ -86,114 +86,24 @@ namespace Roads
     public class CrossingExtras : Turn
     {
         public CrossingData crossingData;
-        [CanBeNull] private Pool arrowPool;
 
-        private bool arrowPoolAvailable;
-        private TurnDirection turnDirection;
-
-        private void Awake()
-        {
-            arrowPool = FindObjectsOfType<Pool>().FirstOrDefault(o => o.CompareTag("ArrowPool"));
-            arrowPoolAvailable = arrowPool != null;
-            if (!arrowPoolAvailable) Debug.LogWarning("Arrow Pool not found");
-        }
-
-        private void Start()
-        {
-            if (comingFrom == RoadDirection.None || goingTo == RoadDirection.None) return;
-            turnDirection = TurnDirectionMapper.GetTurnDirection(comingFrom, goingTo);
-
-            var items = new[] {RoadDirection.West, RoadDirection.North, RoadDirection.East, RoadDirection.South};
-            foreach (var position in items.Where(i => i != comingFrom && i != goingTo))
-            {
-                AddArrows(position);
-            }
-        }
-
-        private void AddArrows(RoadDirection position)
+        protected override Transform RoadDirectionToTransform(RoadDirection position)
         {
-            if (!arrowPoolAvailable) return;
-            Transform t;
             switch (position)
             {
                 case RoadDirection.North:
-                    t = crossingData.north;
-                    break;
+                    return crossingData.north;
                 case RoadDirection.West:
-                    t = crossingData.west;
-                    break;
+                    return crossingData.west;
                 case RoadDirection.East:
-                    t = crossingData.east;
-                    break;
+                    return crossingData.east;
                 case RoadDirection.South:
-                    t = crossingData.south;
-                    break;
+                    return crossingData.south;
                 case RoadDirection.None:
                     throw new ArgumentException("RoadDirection.None not allowed for adding arrows");
                 default:
                     throw new ArgumentOutOfRangeException(nameof(position), position, "Wrong Argument for AddArrows");
             }
-
-            System.Diagnostics.Debug.Assert(arrowPool != null, nameof(arrowPool) + " != null");
-            var arrows = arrowPool.GetItem();
-            SetRotation(arrows, position);
-            arrows.transform.position = t.position;
-        }
-
-        private void SetRotation(GameObject arrows, RoadDirection position)
-        {
-            //by default, the arrow shows to north
-            switch (position)
-            {
-                case RoadDirection.West:
-                {
-                    if (turnDirection == TurnDirection.Left ||
-                        turnDirection == TurnDirection.Straight && goingTo == RoadDirection.South)
-                    {
-                        arrows.transform.Rotate(Vector3.up, 90);
-                    }
-                    else if (turnDirection == TurnDirection.Right ||
-                             turnDirection == TurnDirection.Straight && goingTo == RoadDirection.North)
-                    {
-                        arrows.transform.Rotate(Vector3.up, 90);
-                    }
-
-                    break;
-                }
-                case RoadDirection.North:
-                    if (turnDirection == TurnDirection.Left ||
-                        turnDirection == TurnDirection.Straight && goingTo == RoadDirection.East)
-                    {
-                        arrows.transform.Rotate(Vector3.up, 180);
-                    }
-
-                    break;
-                case RoadDirection.East:
-                    if (turnDirection == TurnDirection.Right ||
-                        turnDirection == TurnDirection.Straight && goingTo == RoadDirection.South)
-                    {
-                        arrows.transform.Rotate(Vector3.up, 90);
-                    }
-                    else if (turnDirection == TurnDirection.Left ||
-                             turnDirection == TurnDirection.Straight && goingTo == RoadDirection.North)
-                    {
-                        arrows.transform.Rotate(Vector3.up, -90);
-                    }
-
-                    break;
-                case RoadDirection.South:
-                    if (turnDirection == TurnDirection.Right ||
-                        turnDirection == TurnDirection.Straight && goingTo == RoadDirection.West)
-                    {
-                        arrows.transform.Rotate(Vector3.up, 180);
-                    }
-
-                    break;
-                case RoadDirection.None:
-                    throw new ArgumentException("RoadDirection.None not allowed for adding arrows");
-                default:
-                    throw new ArgumentOutOfRangeException(nameof(position), position, null);
-            }
         }
     }
 }

+ 1 - 2
Assets/Scripts/Routes/Route.cs

@@ -28,8 +28,7 @@ namespace Routes
         }
     }
     
-    [Serializable]
-    public class Route
+    public class Route : MonoBehaviour
     {
         public List<RouteItem> items;
 

+ 41 - 0
Assets/Scripts/Routes/RouteManager.cs

@@ -0,0 +1,41 @@
+using System;
+using UnityEditor;
+using UnityEngine;
+using Valve.VR.InteractionSystem;
+
+namespace Routes
+{
+    public class RouteManager : MonoBehaviour
+    {
+        public Route[] routes;
+        public int selectedRoute;
+
+        private void Awake()
+        {
+            ShowActiveRoute();
+        }
+
+        private void ShowActiveRoute()
+        {
+            routes.ForEach(r => r.Clear());
+            routes[selectedRoute].Show(); //TODO: maybe show when coming to it
+        }
+
+        private void OnValidate()
+        {
+            ChangeActiveRoute();
+            if (EditorApplication.isPlaying)
+            {
+                ShowActiveRoute();
+            }
+        }
+
+        private void ChangeActiveRoute()
+        {
+            for (int i = 0; i < routes.Length; i++)
+            {
+                routes[i].gameObject.SetActive(i == selectedRoute);
+            }
+        }
+    }
+}

+ 3 - 0
Assets/Scripts/Routes/RouteManager.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: cacf8b05a5264d42ba68303369082ccd
+timeCreated: 1609663650

+ 0 - 17
Assets/Scripts/Routes/Routes.cs

@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace Routes
-{
-    public class Routes : MonoBehaviour
-    {
-        public Route[] routes;
-        public int selectedRoute = -1;
-
-        private void Start()
-        {
-            throw new NotImplementedException();
-        }
-    }
-}

+ 0 - 3
Assets/Scripts/Routes/Routes.cs.meta

@@ -1,3 +0,0 @@
-fileFormatVersion: 2
-guid: c94f7db623b74907b04373ef43f61f45
-timeCreated: 1609611028

+ 99 - 0
Assets/Scripts/Routes/Turn.cs

@@ -1,4 +1,7 @@
 using System;
+using System.Linq;
+using JetBrains.Annotations;
+using Pools;
 using Roads;
 using UnityEngine;
 
@@ -8,5 +11,101 @@ namespace Routes
     {
         public RoadDirection comingFrom;
         public RoadDirection goingTo;
+        
+        [CanBeNull] private Pool arrowPool;
+
+        private bool arrowPoolAvailable;
+        private TurnDirection turnDirection;
+        
+        private void Awake()
+        {
+            arrowPool = FindObjectsOfType<Pool>().FirstOrDefault(o => o.CompareTag("ArrowPool"));
+            arrowPoolAvailable = arrowPool != null;
+            if (!arrowPoolAvailable) Debug.LogWarning("Arrow Pool not found"); 
+        }
+
+        private void Start()
+        {
+            if (comingFrom == RoadDirection.None || goingTo == RoadDirection.None) return;
+            turnDirection = TurnDirectionMapper.GetTurnDirection(comingFrom, goingTo);
+
+            var items = new[] {RoadDirection.West, RoadDirection.North, RoadDirection.East, RoadDirection.South};
+            foreach (var position in items.Where(i => i != comingFrom && i != goingTo))
+            {
+                AddArrows(position);
+            }
+        }
+
+        protected virtual Transform RoadDirectionToTransform(RoadDirection position)
+        {
+            throw new NotImplementedException();
+        }
+        
+        private void AddArrows(RoadDirection position)
+        {
+            if (!arrowPoolAvailable) return;
+            Transform t = RoadDirectionToTransform(position);
+
+            System.Diagnostics.Debug.Assert(arrowPool != null, nameof(arrowPool) + " != null");
+            var arrows = arrowPool.GetItem();
+            SetRotation(arrows, position);
+            arrows.transform.position = t.position;
+        }
+
+        private void SetRotation(GameObject arrows, RoadDirection position)
+        {
+            //by default, the arrow shows to north
+            switch (position)
+            {
+                case RoadDirection.West:
+                {
+                    if (turnDirection == TurnDirection.Left ||
+                        turnDirection == TurnDirection.Straight && goingTo == RoadDirection.South)
+                    {
+                        arrows.transform.Rotate(Vector3.up, 90);
+                    }
+                    else if (turnDirection == TurnDirection.Right ||
+                             turnDirection == TurnDirection.Straight && goingTo == RoadDirection.North)
+                    {
+                        arrows.transform.Rotate(Vector3.up, 90);
+                    }
+
+                    break;
+                }
+                case RoadDirection.North:
+                    if (turnDirection == TurnDirection.Left ||
+                        turnDirection == TurnDirection.Straight && goingTo == RoadDirection.East)
+                    {
+                        arrows.transform.Rotate(Vector3.up, 180);
+                    }
+
+                    break;
+                case RoadDirection.East:
+                    if (turnDirection == TurnDirection.Right ||
+                        turnDirection == TurnDirection.Straight && goingTo == RoadDirection.South)
+                    {
+                        arrows.transform.Rotate(Vector3.up, 90);
+                    }
+                    else if (turnDirection == TurnDirection.Left ||
+                             turnDirection == TurnDirection.Straight && goingTo == RoadDirection.North)
+                    {
+                        arrows.transform.Rotate(Vector3.up, -90);
+                    }
+
+                    break;
+                case RoadDirection.South:
+                    if (turnDirection == TurnDirection.Right ||
+                        turnDirection == TurnDirection.Straight && goingTo == RoadDirection.West)
+                    {
+                        arrows.transform.Rotate(Vector3.up, 180);
+                    }
+
+                    break;
+                case RoadDirection.None:
+                    throw new ArgumentException("RoadDirection.None not allowed for adding arrows");
+                default:
+                    throw new ArgumentOutOfRangeException(nameof(position), position, null);
+            }
+        }
     }
 }

BIN
obj/Debug/Assembly-CSharp-Editor.csprojAssemblyReference.cache


BIN
obj/Debug/Assembly-CSharp.csprojAssemblyReference.cache


BIN
obj/Debug/SteamVR_Windows_EditorHelper.csprojAssemblyReference.cache