private void LoadPrefabSetup() { vehicleName = vehicleBuilderSettings.VehicleName; vehicleModel = vehicleBuilderSettings.VehicleModel; vehicleType = vehicleBuilderSettings.VehicleType; physicsMaterial = vehicleBuilderSettings.PhysicsMaterial; vehicleBodyName = vehicleBuilderSettings.BodyName; frontLeftWheelName = vehicleBuilderSettings.FrontLeftWheelName; frontRightWheelName = vehicleBuilderSettings.FrontRightWheelName; backLeftWheelName = vehicleBuilderSettings.BackLeftWheelName; backRightWheelName = vehicleBuilderSettings.BackRightWheelName; vehicleSettings = vehicleBuilderSettings.VechicleSettings; addEffectsComponent = vehicleBuilderSettings.AddEffectsComponent; smokeParticleSystemPrefab = vehicleBuilderSettings.SmokeParticleSystemPrefab; smokeCount = vehicleBuilderSettings.SmokeCount; trailRendererPrefab = vehicleBuilderSettings.TrailRendererPrefab; trailCount = vehicleBuilderSettings.TrailCount; addExampleInput = vehicleBuilderSettings.AddExampleInput; monoBehaviours = vehicleBuilderSettings.MonoBehaviours; }
private void OnGUI() { if (GUILayout.Button("Build Vehicle", GUILayout.MinHeight(100), GUILayout.Height(50))) { CreateVehicle(); } scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 75f)); CreateLabelField("Vehicle", true); EditorGUILayout.BeginHorizontal(); CreateLabelField("Vehicle Name"); vehicleName = EditorGUILayout.TextField(vehicleName); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); CreateLabelField("Vehicle Model"); vehicleModel = (GameObject)EditorGUILayout.ObjectField(vehicleModel, typeof(GameObject), false); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); CreateLabelField("Vehicle Type"); vehicleType = (VehicleType)EditorGUILayout.EnumPopup(vehicleType); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); CreateLabelField("Physics Material"); physicsMaterial = (PhysicMaterial)EditorGUILayout.ObjectField(physicsMaterial, typeof(PhysicMaterial), false); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); CreateLabelField("Body Name", true); EditorGUILayout.BeginHorizontal(); CreateLabelField("Vehicle Body"); vehicleBodyName = EditorGUILayout.TextField(vehicleBodyName); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); CreateLabelField("Wheel Names", true); if (vehicleType == VehicleType.FourWheels) { DisplayTwoWheels(); DisplayFourWheels(); } else if (vehicleType == VehicleType.TwoWheels) { DisplayTwoWheels(); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); CreateLabelField("Vehicle Settings"); vehicleSettings = (VehicleBehaviourSettings)EditorGUILayout.ObjectField(vehicleSettings, typeof(VehicleBehaviourSettings), false); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); CreateLabelField("Optional Components", true); EditorGUILayout.BeginHorizontal(); CreateLabelField("Add effects component"); addEffectsComponent = EditorGUILayout.Toggle("", addEffectsComponent); EditorGUILayout.EndHorizontal(); if (addEffectsComponent == true) { DisplayEffects(); } EditorGUILayout.BeginHorizontal(); CreateLabelField("Add example input"); addExampleInput = EditorGUILayout.Toggle("", addExampleInput); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); CreateLabelField("Custom components", true); reorderableBehavioursList.DoLayoutList(); UnityEditor.Editor editor = UnityEditor.Editor.CreateEditor(this); editor.DrawDefaultInspector(); EditorGUILayout.EndScrollView(); }