public void GenerateTunnel() { waypoints = new List <Vector3>(); tunnels = new Tunnel[segment]; for (int i = 0; i < segment; i++) { GameObject tunnelObject = Instantiate(tunnelPrefab); Tunnel tunnel = tunnelObject.GetComponent <Tunnel>(); tunnelObject.transform.SetParent(transform); tunnelObject.transform.localScale = Vector3.one; if (i == 0) { tunnelObject.transform.localPosition = Vector3.zero; tunnelObject.transform.localEulerAngles = Vector3.zero; } else { tunnelObject.transform.localPosition = tunnels[i - 1].EdgePosition;// + new Vector3(0f, 0f, tunnels[i-1].transform.localPosition.z); tunnelObject.transform.localEulerAngles = tunnels[i - 1].EdgeRotation; } tunnel.Generate(); foreach (var point in tunnel.Waypoints) { waypoints.Add(point); } tunnels[i] = tunnel; } Debug.Log(waypoints.Count); GenerateWaypoints(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); Tunnel tunnel = (Tunnel)target; if (GUILayout.Button("Generate")) { tunnel.Generate(); } }