Пример #1
0
        void UpdateObjPosAndLocalPos(Transform objectTransform, MapDataPoints mapDataPoints)
        {
            var ObjPosition = LaneLet2MapImporter.GetAverage(mapDataPoints.mapWorldPositions);

            objectTransform.position = ObjPosition;
            // Update child local positions after parent position changed
            mapDataPoints.mapLocalPositions.Clear();
            mapDataPoints.mapLocalPositions = mapDataPoints.mapWorldPositions.Select(p => p - ObjPosition).ToList();
        }
Пример #2
0
        void MoveLaneLines(List <string> laneIds, GameObject mapLaneSection)
        {
            var lanePositions = new List <Vector3>();

            foreach (var laneId in laneIds)
            {
                var lane = Id2Lane[laneId];
                lane.transform.parent = mapLaneSection.transform;
                UpdateObjPosAndLocalPos(lane.transform, lane);
                lanePositions.Add(lane.transform.position);

                var leftLine = Id2LeftLineBoundary[laneId];
                leftLine.transform.parent = mapLaneSection.transform;
                UpdateObjPosAndLocalPos(leftLine.transform, leftLine);

                var rightLine = Id2RightLineBoundary[laneId];
                rightLine.transform.parent = mapLaneSection.transform;
                UpdateObjPosAndLocalPos(rightLine.transform, rightLine);
            }
            // Update mapLaneSection transform based on all lanes and update all lane's positions
            mapLaneSection.transform.position = LaneLet2MapImporter.GetAverage(lanePositions);
            UpdateChildrenPositions(mapLaneSection);
        }