private void DrawCarDetailSection(CoasterCar car) { var newAsset = EditorGUILayout.ObjectField("Drop to add:", car.GameObject, typeof(GameObject), true) as GameObject; if (newAsset != null && newAsset != car.GameObject && newAsset.scene.name != null) // scene name is null for prefabs, yay for unity for checking it this way { car.GameObject = newAsset; } car.CoasterCarType = (CoasterCarType)EditorGUILayout.EnumPopup("Type:", car.CoasterCarType); if (car.CoasterCarType == CoasterCarType.Spinning) { car.SpinFriction = EditorGUILayout.Slider("Spin friction:", car.SpinFriction, 0f, 1f); car.SpinStrength = Mathf.RoundToInt(EditorGUILayout.Slider("Spin strength:", car.SpinStrength / 100f, 0f, 1f) * 100); car.SpinSymmetrySides = EditorGUILayout.IntField("Spin symmetry sides:", car.SpinSymmetrySides); } else if (car.CoasterCarType == CoasterCarType.Swinging) { car.SwingFriction = EditorGUILayout.Slider("Swing friction:", car.SwingFriction, 0f, 1f); car.SwingStrength = EditorGUILayout.Slider("Swing strength:", car.SwingStrength, 0f, 1f); car.SwingMaxAngle = EditorGUILayout.FloatField("Max swing angle:", car.SwingMaxAngle); car.SwingArmLength = EditorGUILayout.FloatField("Swing arm length:", car.SwingArmLength); } car.SeatWaypointOffset = EditorGUILayout.FloatField("Seat waypoint offset:", car.SeatWaypointOffset); car.OffsetFront = EditorGUILayout.FloatField("Offset front:", car.OffsetFront); car.OffsetBack = EditorGUILayout.FloatField("Offset back:", car.OffsetBack); base.Draw(car.GameObject); GUILayout.Space(15); GUILayout.Label("Restraints", "PreToolbar"); for (int i = car.Restraints.Count - 1; i >= 0; i--) { CoasterRestraints restraints = car.Restraints[i]; EditorGUILayout.BeginHorizontal(); GUILayout.Label("#" + i); if (GUILayout.Button("Delete")) { car.Restraints.RemoveAt(i); } EditorGUILayout.EndHorizontal(); restraints.TransformName = EditorGUILayout.TextField("Transform name", restraints.TransformName); restraints.ClosedAngle = EditorGUILayout.FloatField("Closed angle (X-Axis)", restraints.ClosedAngle); } if (GUILayout.Button("Add")) { CoasterRestraints restraints = new CoasterRestraints() { TransformName = "restraint" }; car.Restraints.Add(restraints); } }
private void DrawCarSection() { if (_selectedAsset.GameObject == null) { return; } GUILayout.Label("Car settings:", EditorStyles.boldLabel); if (_selectedAsset.Car == null) { CoasterCar car = new CoasterCar(""); _selectedAsset.Car = car; } _selectedAsset.Car.SeatWaypointOffset = EditorGUILayout.FloatField("Seat waypoint offset:", _selectedAsset.Car.SeatWaypointOffset); _selectedAsset.Car.OffsetFront = EditorGUILayout.FloatField("Offset front:", _selectedAsset.Car.OffsetFront); _selectedAsset.Car.OffsetBack = EditorGUILayout.FloatField("Offset back:", _selectedAsset.Car.OffsetBack); GUILayout.Space(15); GUILayout.Label("Restraints", "PreToolbar"); for (int i = _selectedAsset.Car.Restraints.Count - 1; i >= 0; i--) { CoasterRestraints restraints = _selectedAsset.Car.Restraints[i]; EditorGUILayout.BeginHorizontal(); GUILayout.Label("#" + i); if (GUILayout.Button("Delete")) { _selectedAsset.Car.Restraints.RemoveAt(i); } EditorGUILayout.EndHorizontal(); restraints.TransformName = EditorGUILayout.TextField("Transform name", restraints.TransformName); restraints.ClosedAngle = EditorGUILayout.FloatField("Closed angle (X-Axis)", restraints.ClosedAngle); } if (GUILayout.Button("Add")) { CoasterRestraints restraints = new CoasterRestraints(); restraints.TransformName = "restraint"; _selectedAsset.Car.Restraints.Add(restraints); } DrawSeatsDetailSection(_selectedAsset.GameObject); }
private void DrawCarDetailSection(CoasterCar car) { var newAsset = EditorGUILayout.ObjectField("Drop to add:", car.GameObject, typeof(GameObject), true) as GameObject; if (newAsset != null && newAsset != car.GameObject && newAsset.scene.name != null) // scene name is null for prefabs, yay for unity for checking it this way { car.GameObject = newAsset; } car.SeatWaypointOffset = EditorGUILayout.FloatField("Seat waypoint offset:", car.SeatWaypointOffset); car.OffsetFront = EditorGUILayout.FloatField("Offset front:", car.OffsetFront); car.OffsetBack = EditorGUILayout.FloatField("Offset back:", car.OffsetBack); DrawSeatsDetailSection(car.GameObject); GUILayout.Space(15); GUILayout.Label("Restraints", "PreToolbar"); for (int i = car.Restraints.Count - 1; i >= 0; i--) { CoasterRestraints restraints = car.Restraints[i]; EditorGUILayout.BeginHorizontal(); GUILayout.Label("#" + i); if (GUILayout.Button("Delete")) { car.Restraints.RemoveAt(i); } EditorGUILayout.EndHorizontal(); restraints.TransformName = EditorGUILayout.TextField("Transform name", restraints.TransformName); restraints.ClosedAngle = EditorGUILayout.FloatField("Closed angle (X-Axis)", restraints.ClosedAngle); } if (GUILayout.Button("Add")) { CoasterRestraints restraints = new CoasterRestraints(); restraints.TransformName = "restraint"; car.Restraints.Add(restraints); } }