/// <summary> /// Place a gameobject on the road at marker 0 looking at marker 1 /// </summary> private void AutoPlaceGameObject() { if (!editor.extension.roadSettings.autoPlaceGameObject) { return; } if (editor.extension.roadSettings.placementGameObject == null) { Debug.LogError("No GameObject specified"); return; } ERRoadNetwork erRoadNetwork = new ERRoadNetwork(); ERRoad erRoad = erRoadNetwork.GetRoadByGameObject(editor.extension.roadSettings.road); if (erRoad == null) { Debug.LogError("No road gameobject specified"); return; } if (erRoad.GetMarkerCount() < 2) { Debug.LogError("At least 2 markers required"); return; } GameObject gameObject = editor.extension.roadSettings.placementGameObject; // get marker with index 0 and 1 Vector3 positionA = erRoad.GetMarkerPosition(0); Vector3 positionB = erRoad.GetMarkerPosition(1); Bounds prefabBounds = BoundsUtils.GetPrefabBounds(gameObject); // position at marker position gameObject.transform.position = positionA; // look at 2nd marker gameObject.transform.LookAt(positionB); }
public void ClearRoad() { erRoad = erRoadNetwork.GetRoadByGameObject(road.objectReferenceValue as GameObject); if (erRoad == null) { Debug.LogError("No road gameobject specified"); return; } // the mask didn't get refreshed with the road, it stayed the old one => according to raoul this helps: Object.DestroyImmediate(erRoad.gameObject.GetComponent <AwesomeTechnologies.VegetationMaskLine>()); // delete all markers // TODO: find out how to do that properly while (erRoad.GetMarkerCount() > 0) { erRoad.DeleteMarker(0); } erRoad.Refresh(); }