public void UndoUpdate() { if (roadCreator == null) { roadCreator = (RoadCreator)target; } }
public AStarHelper(Transform destiny, RoadCreator creator) { this.creator = creator; destination = destiny; ArrayList original = new ArrayList(); if(creator.lastIdx == 0){ RoadNode rn0 = new RoadNode(0, creator.lastChunk, creator.lastRotY, 0, creator, original, destination); rn0.mountPoint.name = "Astar-0"; open.Add(rn0, rn0); RoadNode rn1 = new RoadNode(1, creator.lastChunk, creator.lastRotY, 0, creator, original, destination); rn1.mountPoint.name = "Astar-1"; open.Add(rn1, rn1); RoadNode rn2 = new RoadNode(2, creator.lastChunk, creator.lastRotY, 0, creator, original, destination); rn2.mountPoint.name = "Astar-2"; open.Add(rn2, rn2); expanded=3; } else { RoadNode rn0 = new RoadNode(0, creator.lastChunk, creator.lastRotY, 0, creator, original, destination); rn0.mountPoint.name = "Astar-0"; open.Add(rn0, rn0); expanded=1; } }
/// <summary> /// Fired when the mouse moves over canvas /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MouseMovesOnCanvasEventHandler(object sender, MouseEventArgs e) { //location mouse on canvas X.Text = ((int)e.GetPosition(Canvas).X).ToString(); Y.Text = ((int)e.GetPosition(Canvas).Y).ToString(); // drawing Ghost Building if (Tool == Tools.Building) { BuildingCreator.DrawGhost(e.GetPosition(Canvas), Canvas); } // drawin Ghost Garage if (Tool == Tools.Garage) { GarageCreator.DrawGhost(e.GetPosition(Canvas), Canvas); } if (e.LeftButton == MouseButtonState.Pressed) { leftButtonWasPressed = true; // drawing Ghost Road if (Tool == Tools.Road) { RoadCreator.DrawGhost(e.GetPosition(Canvas), Canvas, ObjectHandler.Roads); } } }
public AStarHelper(Transform destiny, RoadCreator creator) { this.creator = creator; destination = destiny; ArrayList original = new ArrayList(); if (creator.lastIdx == 0) { RoadNode rn0 = new RoadNode(0, creator.lastChunk, creator.lastRotY, 0, creator, original, destination); rn0.mountPoint.name = "Astar-0"; open.Add(rn0, rn0); RoadNode rn1 = new RoadNode(1, creator.lastChunk, creator.lastRotY, 0, creator, original, destination); rn1.mountPoint.name = "Astar-1"; open.Add(rn1, rn1); RoadNode rn2 = new RoadNode(2, creator.lastChunk, creator.lastRotY, 0, creator, original, destination); rn2.mountPoint.name = "Astar-2"; open.Add(rn2, rn2); expanded = 3; } else { RoadNode rn0 = new RoadNode(0, creator.lastChunk, creator.lastRotY, 0, creator, original, destination); rn0.mountPoint.name = "Astar-0"; open.Add(rn0, rn0); expanded = 1; } }
/// <summary> /// Redraw all objects on Canvas /// </summary> public static void RedrawAllObjects(Canvas canvas) { //clear canvas canvas.Children.Clear(); //draw roads foreach (var road in Roads) { RoadCreator.DrawRoad(canvas, road); } //draw Buildings foreach (var building in Buildings) { BuildingCreator.DrawBuilding(canvas, building); } //draw Garages foreach (var garage in Garages) { GarageCreator.drawGarage(canvas, garage); } // check for unnessesary intersection if so remove or nessesary IntersectionCreator.UpdateIntersections(Roads, Intersections); //draw Intersection foreach (var intersection in Intersections) { IntersectionCreator.DrawIntersection(canvas, intersection); } }
private void OnEnable() { roadCreator = (RoadCreator)target; roadCreator.Setup(); roadCreator.aDown = false; roadCreator.pDown = false; roadCreator.sDown = false; roadCreator.dDown = false; lastTool = Tools.current; Tools.current = Tool.None; Undo.undoRedoPerformed += UndoUpdate; Undo.undoRedoPerformed += roadCreator.UndoUpdate; if (roadCreator.startIntersection != null) { roadCreator.startIntersection.FixConnectionReferences(); } if (roadCreator.endIntersection != null) { roadCreator.endIntersection.FixConnectionReferences(); } }
// Use this for initialization void Start() { curvePath = FindObjectOfType <PathCreator>().curvePath; roadCreator = FindObjectOfType <RoadCreator>(); StartCoroutine(GenerateNextPoint()); }
private void OnEnable() { roadCreator = (RoadCreator)target; if (roadCreator.road == null) { roadCreator.GetRoad(); } road = roadCreator.road; }
public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); settings.pointSize = Mathf.Max(0.2f, EditorGUILayout.FloatField("Point Size", settings.pointSize)); if (EditorGUI.EndChangeCheck() == true) { Transform[] objects = GameObject.FindObjectsOfType <Transform>(); for (int i = 0; i < objects.Length; i++) { if (objects[i].name.Contains("Connection Point") || objects[i].name == "Start Point" || objects[i].name == "Control Point" || objects[i].name == "End Point") { objects[i].GetComponent <BoxCollider>().size = new Vector3(settings.pointSize, settings.pointSize, settings.pointSize); } } } EditorGUI.BeginChangeCheck(); settings.resolution = Mathf.Clamp(EditorGUILayout.FloatField("Resolution", settings.resolution), 0.01f, 2f); if (EditorGUI.EndChangeCheck() == true) { Transform[] objects = GameObject.FindObjectsOfType <Transform>(); for (int i = 0; i < objects.Length; i++) { RoadCreator road = objects[i].GetComponent <RoadCreator>(); if (road != null) { road.CreateMesh(); } else { Roundabout roundabout = objects[i].GetComponent <Roundabout>(); if (roundabout != null) { roundabout.GenerateMeshes(); } } } } settings.ignoreMouseRayLayer = Mathf.Clamp(EditorGUILayout.IntField("Ignore Mouse Ray Layer", settings.ignoreMouseRayLayer), 9, 31); settings.roadLayer = Mathf.Clamp(EditorGUILayout.IntField("Road Layer", settings.roadLayer), 9, 31); settings.intersectionPointsLayer = Mathf.Clamp(EditorGUILayout.IntField("Intersection Points Layer", settings.intersectionPointsLayer), 9, 31); EditorGUI.BeginChangeCheck(); settings.amountRoadGuidelines = Mathf.Clamp(EditorGUILayout.IntField("Amount Of Road Guidelines (each side)", settings.amountRoadGuidelines), 0, 15); if (EditorGUI.EndChangeCheck() == true) { settings.UpdateRoadGuidelines(); } settings.debug = EditorGUILayout.Toggle("Debug", settings.debug); }
void OnGUI() { RoadCreator road_creator = this.tool_control.road_creator; if (road_creator.road_mesh != null) { GUI.Label(new Rect(100, 100, 100, 20), this.current_block_index.ToString() + " " + road_creator.road_mesh.Length); GUI.Label(new Rect(100, 120, 100, 20), this.current_poly_index + "/" + this.goal_poly_index.ToString()); } }
/// <summary> /// This function is called when the object becomes enabled and active. Create a new path (curve). /// </summary> private void OnEnable() { creator = target as RoadCreator; MeshRenderer renderer = creator.GetComponent <MeshRenderer>(); if (renderer.sharedMaterial == null) { renderer.sharedMaterial = Resources.Load <Material>("Materials/Road"); } }
// Use this for initialization void Start() { // 预先探测出摄像机的实例 this.game_camera = GameObject.FindGameObjectWithTag("MainCamera"); this.GetComponent <LineRenderer>().SetVertexCount(0); this.positions = new Vector3[POSITION_NUM_MAX]; this.road_creator = new RoadCreator(); }
public void CreateMesh(bool fromRoad = false) { if (settings == null) { settings = RoadCreatorSettings.GetSerializedSettings(); } for (int i = 0; i < connections.Count; i++) { if (connections[i].road == null) { connections.RemoveAt(i); } } if (connections.Count < 2 && roundaboutMode == false) { RemoveIntersection(); } else { CheckMaterialsAndPrefabs(); if (resetCurvePointsOnUpdate == true) { ResetCurvePointPositions(); } if (roundaboutMode == true) { Roundabout.GenerateRoundabout(this); } else { if (outerExtraMeshesAsRoads == true) { ResetExtraMeshes(); CreateExtraMeshesFromRoads(); } GenerateMesh(); } } if (fromRoad == false) { for (int i = 0; i < connections.Count; i++) { RoadCreator roadCreator = connections[i].road.transform.parent.parent.parent.parent.GetComponent <RoadCreator>(); roadCreator.CreateMesh(true); } } }
private void MouseReleaseOnCanvasEventHandler(object sender, MouseEventArgs e) { if (leftButtonWasPressed == true) { leftButtonWasPressed = false; // drawing Real Road if (Tool == Tools.Road) { RoadCreator.CreateRoad(Canvas, ObjectHandler.Roads, ObjectHandler.Buildings, ObjectHandler.Garages); } } }
// 开始测试运行 public void startTestRun() { // 播放环境音效 this.GetComponent <AudioSource>().Play(); RoadCreator road_creator = this.tool_control.road_creator; if (road_creator.split_points.Length > 2) { int s = road_creator.split_points[road_creator.split_points.Length - 1 - 1]; int e = road_creator.split_points[road_creator.split_points.Length - 1]; this.goal_poly_index = e - s; } }
public void ResetObject() { if (roadCreator == null) { roadCreator = (RoadCreator)target; } for (int i = roadCreator.transform.GetChild(0).childCount - 1; i >= 0; i--) { Undo.DestroyObjectImmediate(roadCreator.transform.GetChild(0).GetChild(i).gameObject); } roadCreator.startIntersectionConnectionIndex = -1; roadCreator.endIntersectionConnectionIndex = -1; }
void CreateRoadObject(bool isClosed) { // Get even points Vector2[] evenPoints = unevenPath.CalculateEvenlySpacedPoints(spacing); // Create Road object target = new GameObject("RoadObject"); MeshFilter mFilter = target.AddComponent <MeshFilter>(); MeshRenderer mRenderer = target.AddComponent <MeshRenderer>(); // Draw Path Mesh mesh = RoadCreator.CreateRoadMesh(evenPoints, isClosed, roadWidth); mFilter.mesh = mesh; int textureRepeat = Mathf.RoundToInt(tiling * evenPoints.Length * spacing * 0.05f); mRenderer.material = material; mRenderer.material.mainTextureScale = new Vector2(1, textureRepeat); }
private void OnEnable() { roadCreator = (RoadCreator)target; if (roadCreator.transform.childCount == 0) { GameObject segments = new GameObject("Segments"); segments.transform.SetParent(roadCreator.transform); } if (roadCreator.globalSettings == null) { roadCreator.globalSettings = GameObject.FindObjectOfType <GlobalSettings>(); } lastTool = Tools.current; Tools.current = Tool.None; Undo.undoRedoPerformed += UndoUpdate; }
public void ResetObject() { if (roadCreator == null) { roadCreator = (RoadCreator)target; } for (int i = roadCreator.transform.GetChild(0).childCount - 1; i >= 0; i--) { Undo.DestroyObjectImmediate(roadCreator.transform.GetChild(0).GetChild(i).gameObject); } if (roadCreator.followObject != null) { for (int i = 0; i < 2; i++) { for (int j = roadCreator.followObject.transform.GetChild(i).childCount - 1; j >= 0; j -= 1) { Undo.DestroyObjectImmediate(roadCreator.followObject.transform.GetChild(i).GetChild(j).gameObject); } } } }
public RoadNode(int idx, Transform prevChunk, float prevRotY, int prevCost, RoadCreator creator, ArrayList pathUntilNow, Transform destiny) { this.creator = creator; this.chunkIdx=idx; this.destination = destiny; this.pathUntilNow = (ArrayList)pathUntilNow.Clone(); this.pathUntilNow.Add(chunkIdx); GameObject currentChunk = UnityEngine.Object.Instantiate (creator.roadChunks[chunkIdx]) as GameObject; currentChunk.collider.enabled=false; currentChunk.name= "Astar"; currentChunk.tag="starchunk"; this.overlap = creator.putChunk(prevChunk, prevRotY, currentChunk); this.mountPoint = currentChunk.GetComponent<RoadChunk>().mountPoint; this.costSoFar = prevCost + Mathf.Abs((int)(this.mountPoint.transform.localPosition.x)) + Mathf.Abs((int)(this.mountPoint.transform.localPosition.z)); this.rotY = prevRotY + mountPoint.localRotation.eulerAngles.y; }
GameObject DrawTroncon(Feature feature) { MultiLineString itineraire = feature.Geometry as MultiLineString; string id_itineraire = feature.Properties["ID"].ToString(); double largeur_itineraire = (double)feature.Properties["LARGEUR"]; GameObject road = new GameObject(id_itineraire); RoadCreator roadCreator = road.AddComponent <RoadCreator>(); roadCreator.spacing = 1f; roadCreator.roadWidth = (float)largeur_itineraire; roadCreator.material = material; roadCreator.tiling = 2; Path path = road.GetComponent <Path>(); //path.AutoSetControlPoints = true; path.points = new List <Vector3>(); foreach (LineString troncon in itineraire.Coordinates) { foreach (IPosition position in troncon.Coordinates) { if (position.Altitude.HasValue) { if (position.Altitude.Value < 250) { altitude = position.Altitude.Value; } } path.AddSegment(GeoUtils.GeoToWorldPosition(position.Latitude, position.Longitude, altitude, refPoint, scale)); } } return(road); }
public RoadNode(int idx, Transform prevChunk, float prevRotY, int prevCost, RoadCreator creator, ArrayList pathUntilNow, Transform destiny) { this.creator = creator; this.chunkIdx = idx; this.destination = destiny; this.pathUntilNow = (ArrayList)pathUntilNow.Clone(); this.pathUntilNow.Add(chunkIdx); GameObject currentChunk = UnityEngine.Object.Instantiate(creator.roadChunks[chunkIdx]) as GameObject; currentChunk.collider.enabled = false; currentChunk.name = "Astar"; currentChunk.tag = "starchunk"; this.overlap = creator.putChunk(prevChunk, prevRotY, currentChunk); this.mountPoint = currentChunk.GetComponent <RoadChunk>().mountPoint; this.costSoFar = prevCost + Mathf.Abs((int)(this.mountPoint.transform.localPosition.x)) + Mathf.Abs((int)(this.mountPoint.transform.localPosition.z)); this.rotY = prevRotY + mountPoint.localRotation.eulerAngles.y; }
// ------------------------------------------------------------------------ // // Use this for initialization void Start() { this.tool_gui = this.GetComponent <ToolGUI>(); // カメラのインスタンスを探しておく. this.main_camera = GameObject.FindGameObjectWithTag("MainCamera"); this.tool_camera = this.main_camera.GetComponent <ToolCameraControl>(); this.game_camera = this.main_camera.GetComponent <GameCameraControl>(); this.car_camera = this.main_camera.GetComponent <CarCamera>(); this.tool_camera.enabled = true; this.game_camera.enabled = false; this.car_camera.enabled = false; this.game_control = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControl>(); this.game_control.tool_control = this; // this.line_drawer = (Instantiate(this.LineDrawerPrefab) as GameObject).GetComponent <LineDrawerControl>(); this.line_drawer.root = this; this.waku_object = GameObject.Find("waku"); // this.road_creator = new RoadCreator(); this.tunnel_creator = new TunnelCreator(); this.forest_creator = new ForestCreator(); this.buil_arranger = new BuildingArranger(); this.jump_slope_creator = new JumpSlopeCreator(); this.junction_finder = new JunctionFinder(); this.tunnel_creator.TunnelPrefab = this.TunnelPrefab; this.tunnel_creator.road_creator = this.road_creator; this.tunnel_creator.main_camera = this.main_camera; this.tunnel_creator.tool_gui = this.tool_gui; this.tunnel_creator.create(); this.forest_creator.TreePrefab = this.TreePrefab; this.forest_creator.road_creator = this.road_creator; this.forest_creator.main_camera = this.main_camera; this.forest_creator.tool_gui = this.tool_gui; this.forest_creator.create(); this.buil_arranger.BuildingPrefabs = this.BuildingPrefabs; this.buil_arranger.road_creator = this.road_creator; this.buil_arranger.main_camera = this.main_camera; this.buil_arranger.tool_gui = this.tool_gui; this.buil_arranger.create(); this.jump_slope_creator.JumpSlopePrefab = this.JumpSlopePrefab; this.jump_slope_creator.road_creator = this.road_creator; this.jump_slope_creator.main_camera = this.main_camera; this.jump_slope_creator.tool_gui = this.tool_gui; this.jump_slope_creator.create(); this.junction_finder.create(); // this.game_camera.road_creator = this.road_creator; this.step = STEP.EDIT; }
void Awake() { s_Instance = this; }
void OnEnable() { creator = (RoadCreator)target; }
public void CreateRoadMesh(Vector3[] points, Vector3[] nextSegmentPoints, Vector3 previousPoint, float heightOffset, Transform segment, int smoothnessAmount, RoadCreator roadCreator) { if (roadMaterial == null) { roadMaterial = Resources.Load("Materials/Roads/2 Lane Roads/2L Road") as Material; } for (int i = 0; i < extraMeshOpen.Count; i++) { if (extraMeshMaterial[i] == null) { extraMeshMaterial[i] = Resources.Load("Materials/Asphalt") as Material; } } if (segment.GetSiblingIndex() == 0) { SetGuidelines(points, nextSegmentPoints, true); } else { SetGuidelines(points, nextSegmentPoints, false); } GenerateMesh(points, nextSegmentPoints, previousPoint, heightOffset, segment, transform.GetChild(1).GetChild(0), "Road", roadMaterial, smoothnessAmount, roadCreator, roadPhysicsMaterial); for (int i = 0; i < extraMeshOpen.Count; i++) { float leftYOffset = 0; float xOffset = 0; if (i > 0) { bool foundLast = false; for (int j = i - 1; j > -1; j -= 1) { if (extraMeshLeft[j] == extraMeshLeft[i] && j != i) { if (foundLast == false) { leftYOffset = extraMeshYOffset[j]; foundLast = true; } xOffset += extraMeshWidth[j]; } } } GenerateMesh(points, nextSegmentPoints, previousPoint, heightOffset, segment, transform.GetChild(1).GetChild(i + 1), "Extra Mesh", extraMeshMaterial[i], smoothnessAmount, roadCreator, extraMeshPhysicMaterial[i], xOffset, extraMeshWidth[i], extraMeshYOffset[i], leftYOffset, extraMeshLeft[i]); } }
public override void OnInspectorGUI() { EditorGUI.BeginChangeCheck(); serializedObject.FindProperty("baseRoadMaterial").objectReferenceValue = (Material)EditorGUILayout.ObjectField("Base Road Material", serializedObject.FindProperty("baseRoadMaterial").objectReferenceValue, typeof(Material), false); serializedObject.FindProperty("overlayRoadMaterial").objectReferenceValue = (Material)EditorGUILayout.ObjectField("Overlay Road Material", serializedObject.FindProperty("overlayRoadMaterial").objectReferenceValue, typeof(Material), false); serializedObject.FindProperty("roadPhysicsMaterial").objectReferenceValue = (PhysicMaterial)EditorGUILayout.ObjectField("Road Physic Material", serializedObject.FindProperty("roadPhysicsMaterial").objectReferenceValue, typeof(PhysicMaterial), false); if (EditorGUI.EndChangeCheck() == true) { Change(); } EditorGUI.BeginChangeCheck(); serializedObject.FindProperty("startRoadWidth").floatValue = Mathf.Max(0.01f, EditorGUILayout.FloatField("Start Road Width", serializedObject.FindProperty("startRoadWidth").floatValue)); serializedObject.FindProperty("endRoadWidth").floatValue = Mathf.Max(0.01f, EditorGUILayout.FloatField("End Road Width", serializedObject.FindProperty("endRoadWidth").floatValue)); if (EditorGUI.EndChangeCheck() == true) { Change(); for (int i = 0; i < targets.Length; i++) { RoadCreator roadCreator = ((RoadSegment)targets[i]).transform.parent.parent.GetComponent <RoadCreator>(); RoadSegment roadSegment = (RoadSegment)targets[i]; if (roadSegment.transform.GetSiblingIndex() == roadSegment.transform.parent.childCount - 1) { if (roadCreator.endIntersection != null) { roadCreator.CreateMesh(); roadCreator.endIntersectionConnection.leftPoint = roadSegment.transform.GetChild(1).GetChild(0).GetComponent <MeshFilter>().sharedMesh.vertices[roadSegment.transform.GetChild(1).GetChild(0).GetComponent <MeshFilter>().sharedMesh.vertices.Length - 2] + roadSegment.transform.position; roadCreator.endIntersectionConnection.rightPoint = roadSegment.transform.GetChild(1).GetChild(0).GetComponent <MeshFilter>().sharedMesh.vertices[roadSegment.transform.GetChild(1).GetChild(0).GetComponent <MeshFilter>().sharedMesh.vertices.Length - 1] + roadSegment.transform.position; roadCreator.endIntersection.CreateMesh(); } } else if (roadSegment.transform.GetSiblingIndex() == 0) { if (roadCreator.startIntersection != null) { roadCreator.CreateMesh(); roadCreator.startIntersectionConnection.leftPoint = roadSegment.transform.GetChild(1).GetChild(0).GetComponent <MeshFilter>().sharedMesh.vertices[1] + roadSegment.transform.position; roadCreator.startIntersectionConnection.rightPoint = roadSegment.transform.GetChild(1).GetChild(0).GetComponent <MeshFilter>().sharedMesh.vertices[0] + roadSegment.transform.position; roadCreator.startIntersection.CreateMesh(); } } } } EditorGUI.BeginChangeCheck(); serializedObject.FindProperty("flipped").boolValue = EditorGUILayout.Toggle("Road Flipped", serializedObject.FindProperty("flipped").boolValue); serializedObject.FindProperty("textureTilingY").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Texture Tiling Y Multiplier", serializedObject.FindProperty("textureTilingY").floatValue), 0.01f, 10); if (serializedObject.FindProperty("generateSimpleBridge").boolValue == false && serializedObject.FindProperty("generateCustomBridge").boolValue == false) { serializedObject.FindProperty("terrainOption").enumValueIndex = (int)(RoadSegment.TerrainOption)EditorGUILayout.EnumPopup("Terrain Option", (RoadSegment.TerrainOption)Enum.GetValues(typeof(RoadSegment.TerrainOption)).GetValue(serializedObject.FindProperty("terrainOption").enumValueIndex)); if (serializedObject.FindProperty("terrainOption").enumValueIndex == (int)RoadSegment.TerrainOption.ignore) { GUIStyle style = new GUIStyle(); style.fontStyle = FontStyle.Bold; GUILayout.Space(20); GUILayout.Label("Y Offsets", style); serializedObject.FindProperty("leftStartYOffset").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Left Start Y Offset", serializedObject.FindProperty("leftStartYOffset").floatValue), -10, 10); serializedObject.FindProperty("leftEndYOffset").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Left End Y Offset", serializedObject.FindProperty("leftEndYOffset").floatValue), -10, 10); serializedObject.FindProperty("rightStartYOffset").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Right Start Y Offset", serializedObject.FindProperty("rightStartYOffset").floatValue), -10, 10); serializedObject.FindProperty("rightEndYOffset").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Right End Y Offset", serializedObject.FindProperty("rightEndYOffset").floatValue), -10, 10); } } GUIStyle guiStyle = new GUIStyle(); guiStyle.fontStyle = FontStyle.Bold; GUILayout.Space(20); GUILayout.Label("Bridge", guiStyle); SerializedProperty bridgeSettings = serializedObject.FindProperty("bridgeSettings"); if (serializedObject.FindProperty("generateSimpleBridge").boolValue == true || serializedObject.FindProperty("generateCustomBridge").boolValue == true) { bridgeSettings.FindPropertyRelative("extraWidth").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Extra Width", bridgeSettings.FindPropertyRelative("extraWidth").floatValue), 0, 1); GUILayout.Space(20); } serializedObject.FindProperty("generateSimpleBridge").boolValue = EditorGUILayout.Toggle("Generate Simple Bridge", serializedObject.FindProperty("generateSimpleBridge").boolValue); if (serializedObject.FindProperty("generateSimpleBridge").boolValue == true) { EditorGUILayout.PropertyField(bridgeSettings.FindPropertyRelative("bridgeMaterials"), true); bridgeSettings.FindPropertyRelative("yOffsetFirstStep").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Y Offset First Step", bridgeSettings.FindPropertyRelative("yOffsetFirstStep").floatValue), 0, 2); bridgeSettings.FindPropertyRelative("yOffsetSecondStep").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Y Offset Second Step", bridgeSettings.FindPropertyRelative("yOffsetSecondStep").floatValue), 0, 2); bridgeSettings.FindPropertyRelative("widthPercentageFirstStep").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Width Percentage First Step", bridgeSettings.FindPropertyRelative("widthPercentageFirstStep").floatValue), 0, 1); bridgeSettings.FindPropertyRelative("widthPercentageSecondStep").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Width Percentage Second Step", bridgeSettings.FindPropertyRelative("widthPercentageSecondStep").floatValue), 0, 1); } GUILayout.Space(20); GUILayout.Label("Custom Bridge Mesh", guiStyle); serializedObject.FindProperty("generateCustomBridge").boolValue = EditorGUILayout.Toggle("Generate Custom Bridge", serializedObject.FindProperty("generateCustomBridge").boolValue); if (serializedObject.FindProperty("generateCustomBridge").boolValue == true) { bridgeSettings.FindPropertyRelative("bridgeMesh").objectReferenceValue = (GameObject)EditorGUILayout.ObjectField("Bridge Mesh", bridgeSettings.FindPropertyRelative("bridgeMesh").objectReferenceValue, typeof(GameObject), false); bridgeSettings.FindPropertyRelative("sections").floatValue = (int)Mathf.Clamp(EditorGUILayout.FloatField("Sections", bridgeSettings.FindPropertyRelative("sections").floatValue), 1, 20); bridgeSettings.FindPropertyRelative("yScale").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Y Scale", bridgeSettings.FindPropertyRelative("yScale").floatValue), 0.1f, 10); bridgeSettings.FindPropertyRelative("xOffset").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("X Offset", bridgeSettings.FindPropertyRelative("xOffset").floatValue), -2, 2); bridgeSettings.FindPropertyRelative("adaptToTerrain").boolValue = EditorGUILayout.Toggle("Adapt Bridge To Terrain", bridgeSettings.FindPropertyRelative("adaptToTerrain").boolValue); } GUILayout.Space(20); GUILayout.Label("Pillar Placement", guiStyle); if (serializedObject.FindProperty("generateSimpleBridge").boolValue == true || serializedObject.FindProperty("generateCustomBridge").boolValue == true) { serializedObject.FindProperty("placePillars").boolValue = EditorGUILayout.Toggle("Place Pillars", serializedObject.FindProperty("placePillars").boolValue); if (serializedObject.FindProperty("placePillars").boolValue == true) { serializedObject.FindProperty("pillarPrefab").objectReferenceValue = (GameObject)EditorGUILayout.ObjectField("Prefab", serializedObject.FindProperty("pillarPrefab").objectReferenceValue, typeof(GameObject), false); if (serializedObject.FindProperty("generateCustomBridge").boolValue == true) { serializedObject.FindProperty("adaptGapToCustomBridge").boolValue = EditorGUILayout.Toggle("Adapt To Custom Bridge", serializedObject.FindProperty("adaptGapToCustomBridge").boolValue); if (serializedObject.FindProperty("adaptGapToCustomBridge").boolValue == false || serializedObject.FindProperty("generateCustomBridge").boolValue == false) { serializedObject.FindProperty("pillarGap").floatValue = Mathf.Max(0, EditorGUILayout.FloatField("Gap", serializedObject.FindProperty("pillarGap").floatValue)); serializedObject.FindProperty("pillarPlacementOffset").floatValue = Mathf.Max(0, EditorGUILayout.FloatField("Placement Offset", serializedObject.FindProperty("pillarPlacementOffset").floatValue)); } } else { serializedObject.FindProperty("pillarGap").floatValue = Mathf.Max(0, EditorGUILayout.FloatField("Gap", serializedObject.FindProperty("pillarGap").floatValue)); serializedObject.FindProperty("pillarPlacementOffset").floatValue = Mathf.Max(0, EditorGUILayout.FloatField("Placement Offset", serializedObject.FindProperty("pillarPlacementOffset").floatValue)); } serializedObject.FindProperty("extraPillarHeight").floatValue = Mathf.Max(0, EditorGUILayout.FloatField("Extra Height", serializedObject.FindProperty("extraPillarHeight").floatValue)); if (serializedObject.FindProperty("adaptGapToCustomBridge").boolValue == false) { serializedObject.FindProperty("xPillarScale").floatValue = Mathf.Max(0.1f, EditorGUILayout.FloatField("X Scale", serializedObject.FindProperty("xPillarScale").floatValue)); } else { serializedObject.FindProperty("xPillarScaleMultiplier").floatValue = Mathf.Max(0.1f, EditorGUILayout.FloatField("X Scale Multiplier", serializedObject.FindProperty("xPillarScaleMultiplier").floatValue)); } serializedObject.FindProperty("zPillarScale").floatValue = Mathf.Max(0.1f, EditorGUILayout.FloatField("Z Scale", serializedObject.FindProperty("zPillarScale").floatValue)); EditorGUILayout.PropertyField(serializedObject.FindProperty("pillarRotationDirection"), new GUIContent("Rotation Direction"), true); } } GUILayout.Space(20); GUILayout.Label("Extra Meshes", guiStyle); RoadSegment inspectedSegment = (RoadSegment)target; for (int i = 0; i < inspectedSegment.extraMeshes.Count; i++) { bool open = EditorGUILayout.Foldout(inspectedSegment.extraMeshes[i].open, "Extra Mesh " + i); if (open == true) { bool left = EditorGUILayout.Toggle("Left", inspectedSegment.extraMeshes[i].left); Material baseMaterial = (Material)EditorGUILayout.ObjectField("Base Material", inspectedSegment.extraMeshes[i].baseMaterial, typeof(Material), false); Material overlayMaterial = (Material)EditorGUILayout.ObjectField("Overlay Material", inspectedSegment.extraMeshes[i].overlayMaterial, typeof(Material), false); PhysicMaterial physicMaterial = (PhysicMaterial)EditorGUILayout.ObjectField("Physic Material", inspectedSegment.extraMeshes[i].physicMaterial, typeof(PhysicMaterial), false); float startWidth = Mathf.Max(EditorGUILayout.FloatField("Start Width", inspectedSegment.extraMeshes[i].startWidth), 0); float endWidth = Mathf.Max(EditorGUILayout.FloatField("End Width", inspectedSegment.extraMeshes[i].endWidth), 0); bool flipped = EditorGUILayout.Toggle("Flipped", inspectedSegment.extraMeshes[i].flipped); float yOffset = EditorGUILayout.FloatField("Y Offset", inspectedSegment.extraMeshes[i].yOffset); for (int j = 0; j < targets.Length; j++) { RoadSegment currentSegment = (RoadSegment)targets[j]; if (currentSegment.extraMeshes.Count > i) { currentSegment.extraMeshes[i] = new ExtraMesh(open, left, baseMaterial, overlayMaterial, physicMaterial, startWidth, endWidth, flipped, yOffset); } } if (GUILayout.Button("Duplicate Extra Mesh") == true) { for (int j = 0; j < targets.Length; j++) { RoadSegment currentSegment = (RoadSegment)targets[j]; currentSegment.extraMeshes.Add(currentSegment.extraMeshes[currentSegment.extraMeshes.Count - 1]); GameObject extraMesh = new GameObject("Extra Mesh"); extraMesh.AddComponent <MeshFilter>(); extraMesh.AddComponent <MeshRenderer>(); extraMesh.AddComponent <MeshCollider>(); extraMesh.transform.SetParent(((RoadSegment)targets[i]).transform.GetChild(1)); extraMesh.transform.localPosition = Vector3.zero; extraMesh.layer = LayerMask.NameToLayer("Road"); extraMesh.hideFlags = HideFlags.NotEditable; } } if (GUILayout.Button("Remove Extra Mesh") == true) { for (int j = 0; j < targets.Length; j++) { RoadSegment currentSegment = (RoadSegment)targets[j]; if (currentSegment.extraMeshes.Count > i) { currentSegment.extraMeshes.RemoveAt(i); DestroyImmediate(currentSegment.transform.GetChild(1).GetChild(i + 1).gameObject); } } } } else { for (int j = 0; j < targets.Length; j++) { RoadSegment currentSegment = (RoadSegment)targets[j]; if (currentSegment.extraMeshes.Count > i) { currentSegment.extraMeshes[i] = new ExtraMesh(open, currentSegment.extraMeshes[i].left, currentSegment.extraMeshes[i].baseMaterial, currentSegment.extraMeshes[i].overlayMaterial, currentSegment.extraMeshes[i].physicMaterial, currentSegment.extraMeshes[i].startWidth, currentSegment.extraMeshes[i].endWidth, currentSegment.extraMeshes[i].flipped, currentSegment.extraMeshes[i].yOffset); } } } } if (GUILayout.Button("Add Extra Mesh")) { for (int i = 0; i < targets.Length; i++) { ((RoadSegment)targets[i]).extraMeshes.Add(new ExtraMesh(true, true, (Material)((RoadSegment)targets[i]).settings.FindProperty("defaultBaseMaterial").objectReferenceValue, (Material)((RoadSegment)targets[i]).settings.FindProperty("defaultExtraMeshOverlayMaterial").objectReferenceValue, null, 1, 1, false, 0)); GameObject extraMesh = new GameObject("Extra Mesh"); extraMesh.AddComponent <MeshFilter>(); extraMesh.AddComponent <MeshRenderer>(); extraMesh.AddComponent <MeshCollider>(); extraMesh.transform.SetParent(((RoadSegment)targets[i]).transform.GetChild(1)); extraMesh.transform.localPosition = Vector3.zero; extraMesh.layer = LayerMask.NameToLayer("Road"); extraMesh.hideFlags = HideFlags.NotEditable; } } if (EditorGUI.EndChangeCheck()) { Change(); } GUILayout.Space(20); if (GUILayout.Button("Straighten")) { for (int i = 0; i < targets.Length; i++) { Transform points = ((RoadSegment)targets[i]).transform.GetChild(0); if (points.childCount == 3) { points.parent.GetComponent <RoadSegment>().curved = false; points.GetChild(1).position = Misc.GetCenter(points.GetChild(0).position, points.GetChild(2).position); } points.parent.parent.parent.GetComponent <RoadCreator>().CreateMesh(); } } }
private void GenerateMesh(Vector3[] points, Vector3[] nextSegmentPoints, Vector3 previousPoint, Vector3[] previousVertices, float heightOffset, Transform segment, Transform previousSegment, Transform mesh, string name, Material baseMaterial, Material overlayMaterial, int smoothnessAmount, RoadCreator roadCreator, PhysicMaterial physicMaterial, float xOffset = 0, float width = 0, float yOffset = 0, float leftYOffset = 0, bool extraMeshLeft = true) { Vector3[] vertices = new Vector3[points.Length * 2]; Vector2[] uvs = new Vector2[vertices.Length]; int numTriangles = 2 * (points.Length - 1); int[] triangles = new int[numTriangles * 3]; int verticeIndex = 0; int triangleIndex = 0; float totalDistance = 0; float currentDistance = 0; for (int i = 1; i < points.Length; i++) { totalDistance += Vector3.Distance(points[i - 1], points[i]); } for (int i = 0; i < points.Length; i++) { Vector3 left = Misc.CalculateLeft(points, nextSegmentPoints, previousPoint, i); float correctedHeightOffset = heightOffset; if (i > 0) { currentDistance += Vector3.Distance(points[i - 1], points[i]); } float roadWidth = Mathf.Lerp(startRoadWidth, endRoadWidth, currentDistance / totalDistance); if (i == 0 && previousPoint != Misc.MaxVector3) { correctedHeightOffset = previousPoint.y - points[i].y; } else if (i == points.Length - 1 && nextSegmentPoints != null && nextSegmentPoints.Length == 1) { correctedHeightOffset = nextSegmentPoints[0].y - points[i].y; } if (name == "Road") { vertices[verticeIndex] = (points[i] + left * roadWidth) - segment.position; vertices[verticeIndex].y = correctedHeightOffset + points[i].y - segment.position.y; vertices[verticeIndex + 1] = (points[i] - left * roadWidth) - segment.position; vertices[verticeIndex + 1].y = correctedHeightOffset + points[i].y - segment.position.y; } else { float modifiedXOffset = xOffset + roadWidth; if (extraMeshLeft == true) { vertices[verticeIndex] = (points[i] + left * -modifiedXOffset) - segment.position; vertices[verticeIndex].y = correctedHeightOffset + leftYOffset + points[i].y - segment.position.y; vertices[verticeIndex + 1] = (points[i] + left * (-modifiedXOffset - width)) - segment.position; vertices[verticeIndex + 1].y = correctedHeightOffset + yOffset + points[i].y - segment.position.y; } else { vertices[verticeIndex] = (points[i] + left * (modifiedXOffset + width)) - segment.position; vertices[verticeIndex].y = correctedHeightOffset + yOffset + points[i].y - segment.position.y; vertices[verticeIndex + 1] = (points[i] + left * modifiedXOffset) - segment.position; vertices[verticeIndex + 1].y = correctedHeightOffset + leftYOffset + points[i].y - segment.position.y; } } if (i < points.Length - 1) { triangles[triangleIndex] = verticeIndex; triangles[triangleIndex + 1] = verticeIndex + 2; triangles[triangleIndex + 2] = verticeIndex + 1; triangles[triangleIndex + 3] = verticeIndex + 1; triangles[triangleIndex + 4] = verticeIndex + 2; triangles[triangleIndex + 5] = verticeIndex + 3; } verticeIndex += 2; triangleIndex += 6; } // Terrain deformation if (terrainOption == TerrainOption.deform) { float[,] modifiedHeights; RaycastHit raycastHit; if (Physics.Raycast(points[0] + new Vector3(0, 100, 0), Vector3.down, out raycastHit, Mathf.Infinity, ~(1 << roadCreator.globalSettings.roadLayer | 1 << roadCreator.globalSettings.ignoreMouseRayLayer))) { Terrain terrain = raycastHit.collider.GetComponent <Terrain>(); if (terrain != null) { TerrainData terrainData = terrain.terrainData; modifiedHeights = terrainData.GetHeights(0, 0, terrainData.heightmapWidth, terrainData.heightmapHeight); float zDivisions = Vector3.Distance(points[0], points[1]); for (int i = 0; i < points.Length; i++) { Vector3 forward = (vertices[i * 2 + 1] - vertices[i * 2]).normalized; for (float offset = 0; offset < 1; offset += 1 / zDivisions) { Vector3 leftVertex = vertices[i * 2]; Vector3 rightVertex = vertices[i * 2 + 1]; if (i > 0) { leftVertex = Vector3.Lerp(vertices[(i - 1) * 2], vertices[i * 2], offset); rightVertex = Vector3.Lerp(vertices[(i - 1) * 2 + 1], vertices[i * 2 + 1], offset); } float roadWidth = Mathf.Lerp(startRoadWidth, endRoadWidth, (i / points.Length)); float divisions = Mathf.Max(2f, roadWidth * 10); for (float t = 0; t <= 1; t += 1f / divisions) { Vector3 position = Vector3.Lerp(rightVertex + forward * 2f - new Vector3(0, heightOffset, 0) + segment.transform.position, leftVertex - forward * 2f - new Vector3(0, heightOffset, 0) + segment.transform.position, t); Vector3 localTerrainPoint = position - terrain.transform.position; int terrainPointX = (int)((localTerrainPoint.x / terrainData.size.x) * terrainData.heightmapWidth); float terrainPointY = position.y / terrainData.size.y; int terrainPointZ = (int)((localTerrainPoint.z / terrainData.size.z) * terrainData.heightmapHeight); if (terrainPointX > terrainData.heightmapWidth || terrainPointZ > terrainData.heightmapHeight) { continue; } modifiedHeights[terrainPointZ, terrainPointX] = Mathf.Clamp01(terrainPointY); } } } terrainData.SetHeights(0, 0, modifiedHeights); } } } // First if (previousVertices != null) { if (vertices.Length > 4 && previousVertices.Length > 3) { vertices[0] = previousVertices[previousVertices.Length - 2] + previousSegment.position - segment.position; vertices[1] = previousVertices[previousVertices.Length - 1] + previousSegment.position - segment.position; vertices = fixVertices(0, vertices, (vertices[2] - vertices[4]).normalized); vertices = fixVertices(1, vertices, (vertices[3] - vertices[5]).normalized); } } Mesh generatedMesh = new Mesh(); generatedMesh.vertices = vertices; generatedMesh.triangles = triangles; generatedMesh.uv = uvs; if (name == "Road") { generatedMesh = GenerateUvs(generatedMesh, flipped); } else { generatedMesh = GenerateUvs(generatedMesh, extraMeshLeft); } mesh.GetComponent <MeshFilter>().sharedMesh = generatedMesh; mesh.GetComponent <MeshCollider>().sharedMesh = generatedMesh; mesh.GetComponent <MeshCollider>().sharedMaterial = physicMaterial; if (overlayMaterial == null) { mesh.GetComponent <MeshRenderer>().sharedMaterials = new Material[] { baseMaterial }; } else { mesh.GetComponent <MeshRenderer>().sharedMaterials = new Material[] { baseMaterial, overlayMaterial }; } }
void Awake() { if (!_instance) { _instance = this; } }
public void CreateRoadMesh(Vector3[] points, Vector3[] nextSegmentPoints, Vector3 previousPoint, Vector3[] previousVertices, float heightOffset, Transform segment, Transform previousSegment, RoadCreator roadCreator) { CheckMaterialsAndPrefabs(); if (transform.Find("Bridge") != null) { DestroyImmediate(transform.Find("Bridge").gameObject); } if (transform.Find("Custom Bridge") != null) { DestroyImmediate(transform.Find("Custom Bridge").gameObject); } if (segment.GetSiblingIndex() == 0) { SetGuidelines(points, nextSegmentPoints, true); } else { SetGuidelines(points, nextSegmentPoints, false); } GenerateMesh(points, nextSegmentPoints, previousPoint, previousVertices, heightOffset, segment, previousSegment, transform.GetChild(1).GetChild(0), "Road", baseRoadMaterial, overlayRoadMaterial, roadPhysicsMaterial); GenerateExtraMeshes(points, nextSegmentPoints, previousPoint, previousVertices, heightOffset, segment, previousSegment); GenerateBridges(points, nextSegmentPoints, previousPoint, previousSegment); }
public void CreateRoadMesh(Vector3[] points, Vector3[] nextSegmentPoints, Vector3 previousPoint, Vector3[] previousVertices, float heightOffset, Transform segment, Transform previousSegment, int smoothnessAmount, RoadCreator roadCreator) { if (baseRoadMaterial == null) { baseRoadMaterial = Resources.Load("Materials/Low Poly/Roads/2 Lane Roads/2L Road") as Material; } if (bridgeMaterials == null || bridgeMaterials.Length == 0 || bridgeMaterials[0] == null) { bridgeMaterials = new Material[] { Resources.Load("Materials/Low Poly/Concrete") as Material }; } if (pillarPrefab == null || pillarPrefab.GetComponent <MeshFilter>() == null) { pillarPrefab = Resources.Load("Prefabs/Low Poly/Bridges/Oval Bridge Pillar") as GameObject; } for (int i = 0; i < extraMeshOpen.Count; i++) { if (extraMeshMaterial[i] == null) { extraMeshMaterial[i] = Resources.Load("Materials/Low Poly/Asphalt") as Material; } } if (segment.GetSiblingIndex() == 0) { SetGuidelines(points, nextSegmentPoints, true); } else { SetGuidelines(points, nextSegmentPoints, false); } GenerateMesh(points, nextSegmentPoints, previousPoint, previousVertices, heightOffset, segment, previousSegment, transform.GetChild(1).GetChild(0), "Road", baseRoadMaterial, overlayRoadMaterial, smoothnessAmount, roadCreator, roadPhysicsMaterial); for (int i = 0; i < extraMeshOpen.Count; i++) { float leftYOffset = extraMeshYOffset[i]; float xOffset = 0; float yOffset = heightOffset; if (i > 0) { bool foundLast = false; for (int j = i - 1; j > -1; j -= 1) { if (extraMeshLeft[j] == extraMeshLeft[i] && j != i) { if (foundLast == false) { leftYOffset = extraMeshYOffset[j]; foundLast = true; } xOffset += extraMeshWidth[j]; yOffset += extraMeshYOffset[j]; } } } float currentHeight = heightOffset; for (int j = i - 1; j > -1; j -= 1) { if (extraMeshLeft[j] == extraMeshLeft[i] && j != i) { currentHeight += extraMeshYOffset[j]; } } GenerateMesh(points, nextSegmentPoints, previousPoint, previousVertices, heightOffset, segment, previousSegment, transform.GetChild(1).GetChild(i + 1), "Extra Mesh", extraMeshMaterial[i], null, smoothnessAmount, roadCreator, extraMeshPhysicMaterial[i], xOffset, extraMeshWidth[i], currentHeight + extraMeshYOffset[i], currentHeight, extraMeshLeft[i]); } if (transform.childCount == 3) { DestroyImmediate(transform.GetChild(2).gameObject); } if (bridgeGenerator == BridgeGenerator.simple) { float extraWidthLeft = 0; float extraWidthRight = 0; for (int i = 0; i < extraMeshLeft.Count; i++) { if (extraMeshLeft[i] == true) { extraWidthLeft += extraMeshWidth[i]; } else { extraWidthRight += extraMeshWidth[i]; } } extraWidthLeft += extraWidth; extraWidthRight += extraWidth; BridgeGeneration.GenerateSimpleBridge(points, nextSegmentPoints, previousPoint, this, extraWidthLeft, extraWidthRight, bridgeMaterials); } }
private Vector3[] fixVertices(int position, Vector3[] vertices, Vector3 forward, Transform segment, RoadCreator roadCreator, int change) { int startVertex = 0; for (int i = position; startVertex == 0; i -= change) { if ((i < 1 && change == 2) || (i > vertices.Length - 1 && change == -2)) { return(vertices); } float direction = Vector3.Dot(forward.normalized, (vertices[position] - vertices[i]).normalized); if (direction > 0.0f) { startVertex = i; } } int amount = Mathf.Abs(startVertex - position) / 2; float part = 1f / amount; float index = 0; for (int i = startVertex; index < amount * 2; i += change) { vertices[i] = Vector3.Lerp(vertices[startVertex], vertices[position], part * index); index += 2; } return(vertices); }
private void OnSceneGUI() { Point point = (Point)target; RoadCreator roadCreator = null; PrefabLineCreator prefabLine = null; if (point.roadPoint == true) { roadCreator = point.transform.parent.parent.parent.parent.GetComponent <RoadCreator>(); if (roadCreator.settings == null) { roadCreator.settings = RoadCreatorSettings.GetSerializedSettings(); } } else { prefabLine = point.transform.parent.parent.GetComponent <PrefabLineCreator>(); if (prefabLine.settings == null) { prefabLine.settings = RoadCreatorSettings.GetSerializedSettings(); } } if (point.transform.hasChanged == true) { point.transform.rotation = Quaternion.identity; point.transform.localScale = Vector3.one; if (point.roadPoint == true) { if (point.name == "Control Point") { point.transform.parent.parent.GetComponent <RoadSegment>().curved = true; } else { if (point.transform.parent.parent.GetComponent <RoadSegment>().curved == false) { point.transform.parent.GetChild(1).position = Misc.GetCenter(point.transform.parent.GetChild(0).position, point.transform.parent.GetChild(2).position); } if (point.name == "Start Point" && point.transform.parent.parent.GetSiblingIndex() > 0) { point.transform.parent.parent.parent.GetChild(point.transform.parent.parent.GetSiblingIndex() - 1).GetChild(0).GetChild(2).position = point.transform.position; } else if (point.name == "End Point" && point.transform.parent.parent.GetSiblingIndex() < point.transform.parent.parent.parent.childCount - 1) { point.transform.parent.parent.parent.GetChild(point.transform.parent.parent.GetSiblingIndex() + 1).GetChild(0).GetChild(0).position = point.transform.position; } } roadCreator.CreateMesh(); } else if (prefabLine != null) { prefabLine.PlacePrefabs(); } point.transform.hasChanged = false; } // Draw points if (point.roadPoint == true) { if (point.name == "Control Point") { Handles.color = roadCreator.settings.FindProperty("controlPointColour").colorValue; } else { Handles.color = roadCreator.settings.FindProperty("pointColour").colorValue; } Misc.DrawPoint((RoadCreatorSettings.PointShape)roadCreator.settings.FindProperty("pointShape").intValue, point.transform.position, roadCreator.settings.FindProperty("pointSize").floatValue); } else { if (point.name == "Control Point") { Handles.color = prefabLine.settings.FindProperty("controlPointColour").colorValue; } else { Handles.color = prefabLine.settings.FindProperty("pointColour").colorValue; } Misc.DrawPoint((RoadCreatorSettings.PointShape)prefabLine.settings.FindProperty("pointShape").intValue, point.transform.position, prefabLine.settings.FindProperty("pointSize").floatValue); } }