Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();
        roadCreator.heightOffset        = Mathf.Max(0, EditorGUILayout.FloatField("Y Offset", roadCreator.heightOffset));
        roadCreator.segmentPreset       = (Preset)EditorGUILayout.ObjectField("Segment Preset", roadCreator.segmentPreset, typeof(Preset), false);
        roadCreator.createIntersections = EditorGUILayout.Toggle("Create Intersections", roadCreator.createIntersections);

        if (EditorGUI.EndChangeCheck() == true)
        {
            roadCreator.CreateMesh();
        }

        GUIStyle guiStyle = new GUIStyle();

        guiStyle.fontStyle = FontStyle.Bold;

        if (GUILayout.Button("Reset Road"))
        {
            ResetObject();
        }

        if (GUILayout.Button("Generate Road"))
        {
            roadCreator.CreateMesh();
        }
    }
Exemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();
        roadCreator.heightOffset        = Mathf.Max(0, EditorGUILayout.FloatField("Y Offset", roadCreator.heightOffset));
        roadCreator.smoothnessAmount    = Mathf.Max(0, EditorGUILayout.IntField("Smoothness Amount", roadCreator.smoothnessAmount));
        roadCreator.segmentPreset       = (Preset)EditorGUILayout.ObjectField("Segment Preset", roadCreator.segmentPreset, typeof(Preset), false);
        roadCreator.createIntersections = EditorGUILayout.Toggle("Create Intersections", roadCreator.createIntersections);

        if (EditorGUI.EndChangeCheck() == true)
        {
            roadCreator.CreateMesh();
        }

        GUIStyle guiStyle = new GUIStyle();

        guiStyle.fontStyle = FontStyle.Bold;

        if (roadCreator.globalSettings.debug == true)
        {
            GUILayout.Label("");
            GUILayout.Label("Debug", guiStyle);
            GUILayout.Label(roadCreator.startIntersectionConnectionIndex.ToString());
            GUILayout.Label(roadCreator.endIntersectionConnectionIndex.ToString());
        }

        if (GUILayout.Button("Reset Road"))
        {
            ResetObject();
        }

        if (GUILayout.Button("Generate Road"))
        {
            roadCreator.CreateMesh();
        }
    }
    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);
    }
Exemplo n.º 4
0
    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);
            }
        }
    }
Exemplo n.º 5
0
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();
        roadCreator.heightOffset     = Mathf.Max(0, EditorGUILayout.FloatField("Y Offset", roadCreator.heightOffset));
        roadCreator.smoothnessAmount = Mathf.Max(0, EditorGUILayout.IntField("Smoothness Amount", roadCreator.smoothnessAmount));
        roadCreator.segmentPreset    = (Preset)EditorGUILayout.ObjectField("Segment Preset", serializedObject.FindProperty("segmentPreset").objectReferenceValue, typeof(Preset), false);

        GUIStyle guiStyle = new GUIStyle();

        guiStyle.fontStyle = FontStyle.Bold;

        if (EditorGUI.EndChangeCheck() == true)
        {
            roadCreator.CreateMesh();
        }

        if (roadCreator.globalSettings.debug == true)
        {
            GUILayout.Label("");
            GUILayout.Label("Debug", guiStyle);
            EditorGUILayout.ObjectField(roadCreator.currentSegment, typeof(RoadSegment), true);
        }

        if (GUILayout.Button("Reset Road"))
        {
            roadCreator.currentSegment = null;

            for (int i = roadCreator.transform.GetChild(0).childCount - 1; i >= 0; i--)
            {
                Undo.DestroyObjectImmediate(roadCreator.transform.GetChild(0).GetChild(i).gameObject);
            }
        }

        if (GUILayout.Button("Generate Road"))
        {
            roadCreator.CreateMesh();
        }
    }
Exemplo n.º 6
0
    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();
            }
        }
    }
Exemplo n.º 7
0
    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);
        }
    }
Exemplo n.º 8
0
    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.endIntersection.connections[roadCreator.endIntersectionConnectionIndex].leftPoint  = new SerializedVector3(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.endIntersection.connections[roadCreator.endIntersectionConnectionIndex].rightPoint = new SerializedVector3(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.startIntersection.connections[roadCreator.startIntersectionConnectionIndex].leftPoint  = new SerializedVector3(roadSegment.transform.GetChild(1).GetChild(0).GetComponent <MeshFilter>().sharedMesh.vertices[1] + roadSegment.transform.position);
                        roadCreator.startIntersection.connections[roadCreator.startIntersectionConnectionIndex].rightPoint = new SerializedVector3(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, 10);
        serializedObject.FindProperty("terrainOption").enumValueIndex = (int)(RoadSegment.TerrainOption)EditorGUILayout.EnumPopup("Terrain Option", (RoadSegment.TerrainOption)Enum.GetValues(typeof(RoadSegment.TerrainOption)).GetValue(serializedObject.FindProperty("terrainOption").enumValueIndex));

        GUIStyle guiStyle = new GUIStyle();

        guiStyle.fontStyle = FontStyle.Bold;

        GUILayout.Label("");
        GUILayout.Label("Bridge", guiStyle);
        serializedObject.FindProperty("bridgeGenerator").enumValueIndex = (int)(RoadSegment.BridgeGenerator)EditorGUILayout.EnumPopup("Generator", (RoadSegment.BridgeGenerator)Enum.GetValues(typeof(RoadSegment.BridgeGenerator)).GetValue(serializedObject.FindProperty("bridgeGenerator").enumValueIndex));

        if (serializedObject.FindProperty("bridgeGenerator").enumValueIndex > 0)
        {
            EditorGUILayout.PropertyField(serializedObject.FindProperty("bridgeMaterials"), true);
            serializedObject.FindProperty("yOffsetFirstStep").floatValue          = Mathf.Clamp(EditorGUILayout.FloatField("Y Offset First Step", serializedObject.FindProperty("yOffsetFirstStep").floatValue), 0, 2);
            serializedObject.FindProperty("yOffsetSecondStep").floatValue         = Mathf.Clamp(EditorGUILayout.FloatField("Y Offset Second Step", serializedObject.FindProperty("yOffsetSecondStep").floatValue), 0, 2);
            serializedObject.FindProperty("widthPercentageFirstStep").floatValue  = Mathf.Clamp(EditorGUILayout.FloatField("Width Percentage First Step", serializedObject.FindProperty("widthPercentageFirstStep").floatValue), 0, 1);
            serializedObject.FindProperty("widthPercentageSecondStep").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Width Percentage Second Step", serializedObject.FindProperty("widthPercentageSecondStep").floatValue), 0, 1);
            serializedObject.FindProperty("extraWidth").floatValue = Mathf.Clamp(EditorGUILayout.FloatField("Extra Width", serializedObject.FindProperty("extraWidth").floatValue), 0, 1);

            GUILayout.Label("");
            GUILayout.Label("Pillar Placement", guiStyle);
            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);
                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));
                serializedObject.FindProperty("xzPillarScale").floatValue         = Mathf.Max(0, EditorGUILayout.FloatField("XZ Pillar Scale", serializedObject.FindProperty("xzPillarScale").floatValue));
            }
        }

        if (targets.Length == 1)
        {
            GUILayout.Label("");
            GUILayout.Label("Extra Meshes", guiStyle);
            for (int i = 0; i < serializedObject.FindProperty("extraMeshOpen").arraySize; i++)
            {
                serializedObject.FindProperty("extraMeshOpen").GetArrayElementAtIndex(i).boolValue = EditorGUILayout.Foldout(serializedObject.FindProperty("extraMeshOpen").GetArrayElementAtIndex(i).boolValue, "Extra Mesh " + i);
                if (serializedObject.FindProperty("extraMeshOpen").GetArrayElementAtIndex(i).boolValue == true)
                {
                    serializedObject.FindProperty("extraMeshLeft").GetArrayElementAtIndex(i).boolValue = EditorGUILayout.Toggle("Left", serializedObject.FindProperty("extraMeshLeft").GetArrayElementAtIndex(i).boolValue);
                    serializedObject.FindProperty("extraMeshMaterial").GetArrayElementAtIndex(i).objectReferenceValue       = (Material)EditorGUILayout.ObjectField("Material", serializedObject.FindProperty("extraMeshMaterial").GetArrayElementAtIndex(i).objectReferenceValue, typeof(Material), false);
                    serializedObject.FindProperty("extraMeshPhysicMaterial").GetArrayElementAtIndex(i).objectReferenceValue = (PhysicMaterial)EditorGUILayout.ObjectField("Physic Material", serializedObject.FindProperty("extraMeshPhysicMaterial").GetArrayElementAtIndex(i).objectReferenceValue, typeof(PhysicMaterial), false);
                    serializedObject.FindProperty("extraMeshWidth").GetArrayElementAtIndex(i).floatValue   = Mathf.Max(EditorGUILayout.FloatField("Width", serializedObject.FindProperty("extraMeshWidth").GetArrayElementAtIndex(i).floatValue), 0);
                    serializedObject.FindProperty("extraMeshYOffset").GetArrayElementAtIndex(i).floatValue = EditorGUILayout.FloatField("Y Offset", serializedObject.FindProperty("extraMeshYOffset").GetArrayElementAtIndex(i).floatValue);

                    if (GUILayout.Button("Remove Extra Mesh") == true && ((RoadSegment)target).transform.GetChild(1).childCount > 1)
                    {
                        serializedObject.FindProperty("extraMeshOpen").DeleteArrayElementAtIndex(i);
                        serializedObject.FindProperty("extraMeshLeft").DeleteArrayElementAtIndex(i);
                        serializedObject.FindProperty("extraMeshMaterial").DeleteArrayElementAtIndex(i);
                        serializedObject.FindProperty("extraMeshPhysicMaterial").DeleteArrayElementAtIndex(i);
                        serializedObject.FindProperty("extraMeshWidth").DeleteArrayElementAtIndex(i);
                        serializedObject.FindProperty("extraMeshYOffset").DeleteArrayElementAtIndex(i);

                        for (int j = 0; j < targets.Length; j++)
                        {
                            DestroyImmediate(((RoadSegment)targets[j]).transform.GetChild(1).GetChild(i + 1).gameObject);
                        }
                    }
                }
            }

            if (GUILayout.Button("Add Extra Mesh"))
            {
                serializedObject.FindProperty("extraMeshOpen").InsertArrayElementAtIndex(serializedObject.FindProperty("extraMeshOpen").arraySize);
                serializedObject.FindProperty("extraMeshOpen").GetArrayElementAtIndex(serializedObject.FindProperty("extraMeshOpen").arraySize - 1).boolValue = true;
                serializedObject.FindProperty("extraMeshLeft").InsertArrayElementAtIndex(serializedObject.FindProperty("extraMeshLeft").arraySize);
                serializedObject.FindProperty("extraMeshLeft").GetArrayElementAtIndex(serializedObject.FindProperty("extraMeshLeft").arraySize - 1).boolValue = true;
                serializedObject.FindProperty("extraMeshMaterial").InsertArrayElementAtIndex(serializedObject.FindProperty("extraMeshMaterial").arraySize);
                serializedObject.FindProperty("extraMeshMaterial").GetArrayElementAtIndex(serializedObject.FindProperty("extraMeshMaterial").arraySize - 1).objectReferenceValue = Resources.Load("Materials/Low Poly/Asphalt") as Material;
                serializedObject.FindProperty("extraMeshPhysicMaterial").InsertArrayElementAtIndex(serializedObject.FindProperty("extraMeshPhysicMaterial").arraySize);
                serializedObject.FindProperty("extraMeshWidth").InsertArrayElementAtIndex(serializedObject.FindProperty("extraMeshWidth").arraySize);
                serializedObject.FindProperty("extraMeshWidth").GetArrayElementAtIndex(serializedObject.FindProperty("extraMeshWidth").arraySize - 1).floatValue = 1;
                serializedObject.FindProperty("extraMeshYOffset").InsertArrayElementAtIndex(serializedObject.FindProperty("extraMeshYOffset").arraySize);
                serializedObject.FindProperty("extraMeshYOffset").GetArrayElementAtIndex(serializedObject.FindProperty("extraMeshYOffset").arraySize - 1).floatValue = 0;

                GameObject extraMesh = new GameObject("Extra Mesh");
                extraMesh.AddComponent <MeshFilter>();
                extraMesh.AddComponent <MeshRenderer>();
                extraMesh.AddComponent <MeshCollider>();
                extraMesh.transform.SetParent(((RoadSegment)target).transform.GetChild(1));
                extraMesh.transform.localPosition = Vector3.zero;
                extraMesh.layer     = ((RoadSegment)target).transform.parent.parent.GetComponent <RoadCreator>().globalSettings.roadLayer;
                extraMesh.hideFlags = HideFlags.NotEditable;
            }
        }

        if (EditorGUI.EndChangeCheck())
        {
            Change();
        }
        GUILayout.Label("");

        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();
            }
        }

        if (GameObject.FindObjectOfType <GlobalSettings>().debug == true)
        {
            GUILayout.Label("");
            GUILayout.Label("Debug", guiStyle);
            GUILayout.Label(serializedObject.FindProperty("curved").boolValue.ToString());
            EditorGUILayout.PropertyField(serializedObject.FindProperty("startGuidelinePoints"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("centerGuidelinePoints"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("endGuidelinePoints"), true);
        }
    }
Exemplo n.º 9
0
    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)
        {
            if (point.roadPoint == true)
            {
                if (roadCreator != null)
                {
                    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;
            }

            Handles.CylinderHandleCap(0, point.transform.position, Quaternion.Euler(90, 0, 0), roadCreator.settings.FindProperty("pointSize").floatValue, EventType.Repaint);
        }
        else
        {
            if (point.name == "Control Point")
            {
                Handles.color = prefabLine.settings.FindProperty("controlPointColour").colorValue;
            }
            else
            {
                Handles.color = prefabLine.settings.FindProperty("pointColour").colorValue;
            }

            Handles.CylinderHandleCap(0, point.transform.position, Quaternion.Euler(90, 0, 0), prefabLine.settings.FindProperty("pointSize").floatValue, EventType.Repaint);
        }
    }
Exemplo n.º 10
0
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();
        roadCreator.heightOffset     = Mathf.Max(0, EditorGUILayout.FloatField("Y Offset", roadCreator.heightOffset));
        roadCreator.smoothnessAmount = Mathf.Max(0, EditorGUILayout.IntField("Smoothness Amount", roadCreator.smoothnessAmount));
        roadCreator.segmentPreset    = (Preset)EditorGUILayout.ObjectField("Segment Preset", roadCreator.segmentPreset, typeof(Preset), false);

        if (EditorGUI.EndChangeCheck() == true)
        {
            roadCreator.CreateMesh();
        }

        GameObject lastFollowObject = roadCreator.followObject;

        roadCreator.followObject = (GameObject)EditorGUILayout.ObjectField("Follow Object", roadCreator.followObject, typeof(GameObject), true);

        GUIStyle guiStyle = new GUIStyle();

        guiStyle.fontStyle = FontStyle.Bold;

        if (roadCreator.followObject != lastFollowObject)
        {
            if (roadCreator.followObject != null)
            {
                if (roadCreator.followObject.GetComponent <PrefabLineCreator>() == null)
                {
                    roadCreator.followObject = null;
                    Debug.Log("Follow object must be a prefab line");
                }

                if (roadCreator.followObject != null)
                {
                    // Remove uncompleted segments for current road creator
                    if (roadCreator.transform.GetChild(0).childCount > 0 && roadCreator.transform.GetChild(0).GetChild(roadCreator.transform.GetChild(0).childCount - 1).GetChild(0).childCount < 3)
                    {
                        DestroyImmediate(roadCreator.transform.GetChild(0).GetChild(roadCreator.transform.GetChild(0).childCount - 1).gameObject);
                    }

                    roadCreator.followObject.GetComponent <PrefabLineCreator>().isFollowObject = true;

                    for (int i = 0; i < roadCreator.followObject.transform.GetComponentsInChildren <BoxCollider>().Length; i++)
                    {
                        roadCreator.followObject.transform.GetComponentsInChildren <BoxCollider>()[i].enabled = false;
                    }

                    if (roadCreator.followObject.transform.GetChild(0).childCount > 0 && roadCreator.followObject.transform.GetChild(0).GetChild(roadCreator.followObject.transform.GetChild(0).childCount - 1).name == "Control Point")
                    {
                        // Remove prefab lines last control point
                        DestroyImmediate(roadCreator.followObject.transform.GetChild(0).GetChild(roadCreator.followObject.transform.GetChild(0).childCount - 1).gameObject);
                    }

                    if (roadCreator.followObject.transform.GetChild(0).childCount == 1)
                    {
                        if (roadCreator.transform.GetChild(0).childCount > 0)
                        {
                            roadCreator.followObject.transform.GetChild(0).GetChild(0).position = roadCreator.transform.GetChild(0).GetChild(roadCreator.transform.GetChild(0).childCount - 1).GetChild(0).GetChild(2).position;
                        }
                        else
                        {
                            DestroyImmediate(roadCreator.followObject.transform.GetChild(0).GetChild(0).gameObject);
                        }
                    }
                }
            }

            if (lastFollowObject != null)
            {
                lastFollowObject.GetComponent <PrefabLineCreator>().isFollowObject = false;

                for (int i = 0; i < lastFollowObject.transform.GetComponentsInChildren <BoxCollider>().Length; i++)
                {
                    lastFollowObject.transform.GetComponentsInChildren <BoxCollider>()[i].enabled = true;
                }
            }
        }

        if (roadCreator.globalSettings.debug == true)
        {
            GUILayout.Label("");
            GUILayout.Label("Debug", guiStyle);
        }

        if (GUILayout.Button("Reset Road"))
        {
            ResetObject();
        }

        if (GUILayout.Button("Generate Road"))
        {
            roadCreator.CreateMesh();

            if (roadCreator.followObject != null)
            {
                roadCreator.followObject.GetComponent <PrefabLineCreator>().PlacePrefabs();
            }
        }

        if (GUILayout.Button("Convert To Mesh"))
        {
            Misc.ConvertToMesh(roadCreator.gameObject, "Road Mesh");
        }
    }
Exemplo n.º 11
0
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();
        roadCreator.heightOffset  = Mathf.Max(0, EditorGUILayout.FloatField("Y Offset", roadCreator.heightOffset));
        roadCreator.segmentPreset = (Preset)EditorGUILayout.ObjectField("Segment Preset", roadCreator.segmentPreset, typeof(Preset), false);

        if (roadCreator.segmentPreset == null)
        {
            roadCreator.segmentToCopy = (RoadSegment)EditorGUILayout.ObjectField("Segment To Copy", roadCreator.segmentToCopy, typeof(RoadSegment), true);
        }

        roadCreator.resolutionMultiplier = Mathf.Clamp(EditorGUILayout.FloatField("Resoltion Multiplier", roadCreator.resolutionMultiplier), 0.01f, 10f);
        roadCreator.createIntersections  = EditorGUILayout.Toggle("Create Intersections", roadCreator.createIntersections);
        roadCreator.generateCollider     = EditorGUILayout.Toggle("Generate Collider", roadCreator.generateCollider);

        GUIStyle guiStyle = new GUIStyle();

        guiStyle.fontStyle = FontStyle.Bold;

        if (roadCreator.startIntersection != null)
        {
            GUILayout.Space(20);
            GUILayout.Label("Start Intersection Lane Markings", guiStyle);
            roadCreator.startLanes = Mathf.Clamp(EditorGUILayout.IntField("Lanes", roadCreator.startLanes), 0, 10);

            if (roadCreator.startLanes > 0)
            {
                roadCreator.startMarkersScale      = Mathf.Clamp(EditorGUILayout.FloatField("Scale", roadCreator.startMarkersScale), 0.1f, 5f);
                roadCreator.startMarkersRepeations = Mathf.Clamp(EditorGUILayout.IntField("Repeations", roadCreator.startMarkersRepeations), 1, 5);
                roadCreator.startMarkersStartIntersectionOffset = Mathf.Clamp(EditorGUILayout.FloatField("Start Intersection Offset", roadCreator.startMarkersStartIntersectionOffset), 0.7f * roadCreator.startMarkersScale, 5);

                if (roadCreator.startMarkersRepeations > 1)
                {
                    roadCreator.startMarkersContinuousIntersectionOffset = Mathf.Clamp(EditorGUILayout.FloatField("Continuous Offset", roadCreator.startMarkersContinuousIntersectionOffset), 1.4f * roadCreator.startMarkersScale, 25);
                }

                roadCreator.startMarkersYOffset = Mathf.Max(EditorGUILayout.FloatField("Y Offset", roadCreator.startMarkersYOffset), 0f);

                GUILayout.Space(20);

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Index");
                GUILayout.Label("Left");
                GUILayout.Label("Forwards");
                GUILayout.Label("Right");
                EditorGUILayout.EndHorizontal();

                for (int i = 0; i < roadCreator.startLanes; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("#" + i);
                    GUILayout.Space(Screen.width / 4 - 20);
                    roadCreator.startLaneMarkers[i].one   = EditorGUILayout.Toggle(roadCreator.startLaneMarkers[i].one);
                    roadCreator.startLaneMarkers[i].two   = EditorGUILayout.Toggle(roadCreator.startLaneMarkers[i].two);
                    roadCreator.startLaneMarkers[i].three = EditorGUILayout.Toggle(roadCreator.startLaneMarkers[i].three);
                    EditorGUILayout.EndHorizontal();
                }

                if (GUILayout.Button("Reset Lane Markers"))
                {
                    for (int i = 0; i < roadCreator.startLanes; i++)
                    {
                        roadCreator.startLaneMarkers[i] = new Vector3Bool(false, true, false);
                    }
                }
            }

            GUILayout.Space(20);
        }

        if (roadCreator.endIntersection != null)
        {
            GUILayout.Space(20);
            GUILayout.Label("End Intersection Lane Markings", guiStyle);
            roadCreator.endLanes = Mathf.Clamp(EditorGUILayout.IntField("Lanes", roadCreator.endLanes), 0, 10);

            if (roadCreator.endLanes > 0)
            {
                roadCreator.endMarkersScale      = Mathf.Clamp(EditorGUILayout.FloatField("Scale", roadCreator.endMarkersScale), 0.1f, 5f);
                roadCreator.endMarkersRepeations = Mathf.Clamp(EditorGUILayout.IntField("Repeations", roadCreator.endMarkersRepeations), 1, 5);
                roadCreator.endMarkersStartIntersectionOffset = Mathf.Clamp(EditorGUILayout.FloatField("Start Intersection Offset", roadCreator.endMarkersStartIntersectionOffset), 0.7f * roadCreator.endMarkersScale, 5);

                if (roadCreator.endMarkersRepeations > 1)
                {
                    roadCreator.endMarkersContinuousIntersectionOffset = Mathf.Clamp(EditorGUILayout.FloatField("Continuous Offset", roadCreator.endMarkersContinuousIntersectionOffset), 1.4f * roadCreator.endMarkersScale, 25);
                }

                roadCreator.endMarkersYOffset = Mathf.Max(EditorGUILayout.FloatField("Y Offset", roadCreator.endMarkersYOffset), 0f);

                GUILayout.Space(20);

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Index");
                GUILayout.Label("Left");
                GUILayout.Label("Forwards");
                GUILayout.Label("Right");
                EditorGUILayout.EndHorizontal();

                for (int i = 0; i < roadCreator.endLanes; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("#" + i);
                    GUILayout.Space(Screen.width / 4 - 20);
                    roadCreator.endLaneMarkers[i].one   = EditorGUILayout.Toggle(roadCreator.endLaneMarkers[i].one);
                    roadCreator.endLaneMarkers[i].two   = EditorGUILayout.Toggle(roadCreator.endLaneMarkers[i].two);
                    roadCreator.endLaneMarkers[i].three = EditorGUILayout.Toggle(roadCreator.endLaneMarkers[i].three);
                    EditorGUILayout.EndHorizontal();
                }

                if (GUILayout.Button("Reset Lane Markers"))
                {
                    for (int i = 0; i < roadCreator.endLanes; i++)
                    {
                        roadCreator.endLaneMarkers[i] = new Vector3Bool(false, true, false);
                    }
                }
            }

            GUILayout.Space(20);
        }

        if (EditorGUI.EndChangeCheck() == true)
        {
            roadCreator.CreateMesh();
        }

        if (GUILayout.Button("Flip Road"))
        {
            roadCreator.Flip();
        }

        if (GUILayout.Button("Reset Road"))
        {
            ResetObject();
        }

        if (GUILayout.Button("Generate Road"))
        {
            roadCreator.CreateMesh();
        }
    }