public GameObject AddRoad(bool bForceSelect = false) { GSDRoad[] tObj = GetComponentsInChildren <GSDRoad>(); int NewRoadNumber = (tObj.Length + 1); //Road: GameObject tRoadObj = new GameObject("Road" + NewRoadNumber.ToString()); UnityEditor.Undo.RegisterCreatedObjectUndo(tRoadObj, "Created road"); tRoadObj.transform.parent = transform; GSDRoad tRoad = tRoadObj.AddComponent <GSDRoad>(); //Spline: GameObject tSplineObj = new GameObject("Spline"); tSplineObj.transform.parent = tRoad.transform; tRoad.GSDSpline = tSplineObj.AddComponent <GSDSplineC>(); tRoad.GSDSpline.mSplineRoot = tSplineObj; tRoad.GSDSpline.tRoad = tRoad; tRoad.GSDSplineObj = tSplineObj; tRoad.GSDRS = this; tRoad.SetupUniqueIdentifier(); tRoad.ConstructRoad_ResetTerrainHistory(); if (bForceSelect) { UnityEditor.Selection.activeGameObject = tRoadObj; } return(tRoadObj); }