EasyRoads3D V3 Manual
 

 

ERRoadNetwork


Description

This is the base class for an EasyRoads3D road network

 

Constructors

public ERRoadNetwork()

Creates a new road network object in the scene or a reference to an already existing road network in the scene that was created manually in the Unity editor.

 

Static Properties

public static ERRoadNetwork.RoadUpdateCallback onRoadUpdate

Callback triggered after changes to a road object, including a reference to the changed ERRoad instance

 

public static ERRoadNetwork.SideObjectUpdate onSideObjectUpdate

Callback triggered after changes to a side object, including a reference to the changed ERSideObjectInstance  instance

 

public static ERRoadNetwork.BuildModeCallback onBuildModeEnter

Callback triggered after switching to Build Mode

 

public static ERRoadNetwork.EditModeCallback onEditModeEnter

Callback triggered after switching to Edit Mode

 

Functions

 

public void BuildRoadNetwork()

Builds the final road network and manipulates the terrain accordingly

 

public void BuildRoadNetwork(bool splatmaps, bool trees, bool detail)

Builds the final road network and manipulates the terrain according the passed parameters

 

public void BuildRoadNetwork(bool splatmaps, bool trees, bool detail, ERRoad[] roads)

Builds the final road network and manipulates the terrain according the passed parameters. The terrain will only be updated according the passed array of road objects.

NOTE: RestoreRoadNetwork() will target the last build process. Do not use the above consecutively without restoring the road network first if you do want to be able to restore the full road network. This mainly relates to restoring the terrain to its original state of before creating the road network.

 

public void CenterPivotPoints()

This will set the pivot points of all road objects to the center of the bounding box. This will be reset after each road update so it is recommended to use this only for testing and final builds.

 

public ERRoad ConnectRoads(ERRoad road1, ERRoad road2)

Connects two roads at the nearest markers.

 

public ERRoad ConnectRoads(ERRoad road1, int markerIndex1, ERRoad road2, int markerIndex2)

Connects two roads between markerIndex1 and markerIndex2.

 

public ERRoad CreateRoad(string name)

Creates a new road object and returns it

 

public ERRoad CreateRoad(string name, Vector3[] markers)

Creates and builds a new road object according the passed array of marker positons and returns it

 

public ERRoad CreateRoad(string name, ERRoadType type)

Creates and a new road object of ERRoadType type and returns it

 

public ERRoad CreateRoad(string name, ERRoadType type, Vector3[] markers)

Creates and builds a new road object of ERRoadType type and according the passed array of marker positons and returns it

 

public void FinalizeObjects()

This will remove all script components from all road network game objects including the main road network script.

 

public ERConnection GetConnectionByName(string name)

Returns the connection in the scene matching name

 

public ERConnection[] GetConnections()

Returns all available connections

 

public float GetRaiseOffset()

Returns the raise level of the road network relative to the terrain height

 

public ERRoad[] GetRoadObjects()

Returns all current road objects in the road network

 

public ERRoad GetRoadByGameObject(GameObject object)

Finds a road object by GameObject and returns it

 

public ERRoad GetRoadByName(string name)

Finds a road object by name and returns it

 

public ERRoadType GetRoadTypeByName(string name)

Returns a road type by name and returns it

 

public ERRoadType[] GetRoadTypes()

Returns all available road types

 

public SideObject GetSideObjectByName(string name)

Finds the side object by name and returns it

 

public bool SideObjectIsDualSided(SideObject obj)

Returns true when the passed side object can be used on both sides of a road object

 

public ERConnection GetConnectionPrefabByName(string name)

Returns the connection prefab in /Assets/EasyRoads3D/Resources/custom prefabs/ or /Assets/EasyRoads3D/Resources/dynamic prefabs/ matching name

 

public void HideWhiteSurfaces(bool value)

Enables/disables visibility of the white surfaces surrounding the road objects

 

public ERConnection InstantiateConnection(ERConnection connectionPrefab, string name, Vector3 position, Vector3 euler)

Instantiates, names and returns a new connection instance of the passed connectionPrefab, name, position and euler rotation angles

 

public ERConnection[] LoadConnections()

Returns all available connections in the Resources folder

 

public void RestoreRoadNetwork()

Restores the road network back to edit mode

 

public void SetRaiseOffset(float value)

This will raise the road network in Build Mode above the terrain according the passed value

 

public void Translate(Vector3 translation)

This will move the entire road network according the Vector3 translation

 

public void UpdateTerrainInfo()

This will update the terrain data. Call this at runtime when new terrains are added to the scene and when these terrains should be updated according the road network shape.