/// <summary> /// Create the road mesh for this object. /// </summary> /// <param name="baseObject">The base (main) object</param> private void CreateRoadLayout(GameObject baseObject, bool createMesh) { RoadConstructorHelper.CrossSectionDetails = CrossSectionDetails; RoadConstructorHelper.Lighting = Lighting; RoadConstructorHelper.MaterialFrequencySet = this; RoadConstructorHelper.BaseNodeLayoutNode = baseObject.GetComponent <RoadNetworkLayout>(); RoadConstructorHelper.SetUVValues(UvSet); Transform[] allChildren = baseObject.GetComponentsInChildren <Transform>(true); foreach (Transform child in allChildren) { RoadNetworkNode rub = child.GetComponent <RoadNetworkNode>(); if (rub != null) { if (rub.Details.Union == RoadNetworkNode.UNION_TYPE.NONE) { continue; } foreach (RoadNetworkNode rnn in rub.Details.Roads) { if (rnn.Details.Modified) { rub.Details.ModifiedSecondHand = true; } } rub.CreateUnion(); if (rub.RoadUnion != null) { rub.RoadUnion.CreateLayout(this); if (MeshPerNode) { RoadConstructorHelper.CreateMeshAndCollisionComponents(rub.gameObject); } else { RoadConstructorHelper.CreateMeshAndCollisionComponents(baseObject); } } } } foreach (Transform child in allChildren) { RoadNetworkNode rub = child.GetComponent <RoadNetworkNode>(); if (rub != null) { if (rub.Details.Union == RoadNetworkNode.UNION_TYPE.NONE) { continue; } rub.RoadUnion.CreateStreetLayout(this); } } if (createMesh) { if (DropToGround) { DropToGroundHelper.StepDropRoad(); } foreach (Transform child in allChildren) { RoadNetworkNode rub = child.GetComponent <RoadNetworkNode>(); if (rub != null) { if (rub.Details.Union == RoadNetworkNode.UNION_TYPE.NONE) { continue; } if (MeshPerNode) { if (rub.Details.IsNeighbourModified) { rub.RoadUnion.CreateMesh(rub.BuildData); } } else { rub.RoadUnion.CreateMesh(this); } } } } if (createMesh) { foreach (Transform child in allChildren) { RoadNetworkNode rub = child.GetComponent <RoadNetworkNode>(); if (rub != null) { if (rub.Details.Union == RoadNetworkNode.UNION_TYPE.NONE) { continue; } if (MeshPerNode) { if (rub.Details.IsNeighbourModified) { rub.BuildData.ApplyMeshDetails(rub.gameObject); rub.BuildData.ApplyCollisionDetails(rub.gameObject, CreateCollision); } } } } } if (!MeshPerNode) { ApplyMeshDetails(baseObject); ApplyCollisionDetails(baseObject, CreateCollision); } foreach (Transform child in allChildren) { RoadNetworkNode rub = child.GetComponent <RoadNetworkNode>(); if (rub != null) { rub.Details.Modified = false; rub.Details.ModifiedSecondHand = false; } } }