public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label) { drawer.BeginProperty(position, property, label); VehicleModule = SerializedPropertyHelper.GetTargetObjectOfProperty(drawer.serializedProperty) as VehicleModule; if (VehicleModule == null) { Debug.LogError( "VehicleModule is not a target object of ModuleDrawer. Make sure all modules inherit from VehicleModule."); drawer.EndProperty(); return(false); } bool expanded = drawer.Header(VehicleModule.GetType().Name); if (Application.isPlaying && VehicleModule.VehicleController != null) { if (VehicleModule.VehicleController.stateSettings != null) { DrawStateSettingsBar( position, VehicleModule.VehicleController.stateSettings.LODs.Count, drawer.FindProperty("state.isOn"), drawer.FindProperty("state.isEnabled"), drawer.FindProperty("state.lodIndex")); } } return(expanded); }
public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label) { if (!base.OnNUI(position, property, label)) { return(false); } MetricsModule metrics = SerializedPropertyHelper.GetTargetObjectOfProperty(property) as MetricsModule; if (metrics == null) { drawer.EndProperty(); return(false); } drawer.Label($"Top Speed: {metrics.topSpeed.value}"); drawer.Label($"Average Speed: {metrics.averageSpeed.value}"); drawer.Label($"Odometer: {metrics.odometer.value}"); drawer.Label($"Cont. Drift Distance: {metrics.continousDriftDistance.value}"); drawer.Label($"Cont. Drift Time: {metrics.continousDriftTime.value}"); drawer.Label($"Total Drift Distance: {metrics.totalDriftDistance.value}"); drawer.Label($"Total Drift Time: {metrics.totalDriftTime.value}"); drawer.EndProperty(); return(true); }
public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label) { if (!base.OnNUI(position, property, label)) { return(false); } drawer.Field("useForcedInduction"); drawer.Field("forcedInductionType"); drawer.Field("powerGainMultiplier"); EngineComponent.ForcedInduction forcedInduction = SerializedPropertyHelper.GetTargetObjectOfProperty(property) as EngineComponent.ForcedInduction; if (forcedInduction != null && forcedInduction.forcedInductionType == EngineComponent.ForcedInduction.ForcedInductionType.Turbocharger) { drawer.Field("spoolUpTime", true, "s"); drawer.Field("linearity"); } drawer.Field("boost", false); drawer.EndProperty(); return(true); }
public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label) { if (!base.OnNUI(position, property, label)) { return(false); } drawer.Field("groundDetectionPreset"); GroundDetectionPreset gdPreset = ((GroundDetection)(SerializedPropertyHelper.GetTargetObjectOfProperty(property) as VehicleComponent))?.groundDetectionPreset; if (gdPreset != null) { drawer.EmbeddedObjectEditor(gdPreset, drawer.positionRect); } drawer.BeginSubsection("Debug Info"); GroundDetection groundDetection = SerializedPropertyHelper.GetTargetObjectOfProperty(drawer.serializedProperty) as GroundDetection; if (groundDetection != null && groundDetection.VehicleController != null) { for (int i = 0; i < groundDetection.VehicleController.powertrain.wheels.Count; i++) { WheelComponent wheelComponent = groundDetection.VehicleController.powertrain.wheels[i]; if (wheelComponent != null) { drawer.Label($"{wheelComponent.name}: {wheelComponent.surfacePreset?.name} SurfacePreset"); } } } else { drawer.Info("Debug info is available only in play mode."); } drawer.EndSubsection(); drawer.EndProperty(); return(true); }
public void DrawClipsSection(List <string> clipNames = null, int minClipCount = 1, int maxClipCount = 1, int defaultClipCount = 1) { soundComponentObject = (SerializedPropertyHelper.GetTargetObjectOfProperty(drawer.serializedProperty) as VehicleComponent) as SoundComponent; drawer.ReorderableList("clips"); if (soundComponentObject == null) { return; } if (soundComponentObject.clips.Count > defaultClipCount) { drawer.Space(); drawer.Info("If more than clip is supplied for sound components that require only one, " + "a random clip will be selected each time sound is played."); } }
public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label) { if (!base.OnNUI(position, property, label)) { return(false); } drawer.Field("physicsQuality"); drawer.Space(); if (Application.isPlaying) { Solver solver = SerializedPropertyHelper.GetTargetObjectOfProperty(property) as Solver; drawer.Label($"Simulating {solver.Components.Count} powertrain components.", false, false); } drawer.EndProperty(); return(true); }
public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label) { if (!base.OnNUI(position, property, label)) { return(false); } VehicleController vehicleController = SerializedPropertyHelper.GetTargetObjectWithProperty(property) as VehicleController; if (vehicleController == null) { drawer.EndProperty(); return(false); } ModuleManager moduleManager = SerializedPropertyHelper.GetTargetObjectOfProperty(property) as ModuleManager; if (moduleManager == null) { drawer.EndProperty(); return(false); } moduleManager.VehicleController = vehicleController; if (!Application.isPlaying && (int)EditorApplication.timeSinceStartup % 2 == 0) { moduleManager.ReloadModulesList(); } drawer.Space(); ModuleWrapper[] wrappers = vehicleController.gameObject.GetComponents <ModuleWrapper>(); if (wrappers.Length == 0) { drawer.Info("Use 'Add Component' button to add a module. Modules will appear here as they are added."); drawer.EndProperty(); return(true); } drawer.Label("Module Categories:"); VehicleModule.ModuleCategory[] moduleCategories = moduleManager.modules.Select(m => m.GetModuleCategory()).Distinct().OrderBy(x => x).ToArray(); int categoryIndex = drawer.HorizontalToolbar("moduleCategories", moduleCategories.Select(m => m.ToString()).ToArray()); if (categoryIndex < 0) { categoryIndex = 0; } if (categoryIndex >= moduleCategories.Length) { drawer.EndProperty(); return(true); } drawer.Space(3); VehicleModule.ModuleCategory activeCategory = moduleCategories[categoryIndex]; foreach (ModuleWrapper wrapper in wrappers) { if (wrapper == null || wrapper.GetModule() == null) { continue; } if (wrapper.GetModule().GetModuleCategory() != activeCategory) { continue; } drawer.EmbeddedObjectEditor(wrapper, drawer.positionRect); } drawer.EndProperty(); return(true); }
public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label) { if (!base.OnNUI(position, property, label)) { return(false); } DamageHandler damageHandler = SerializedPropertyHelper.GetTargetObjectOfProperty(property) as DamageHandler; if (damageHandler == null) { drawer.EndProperty(); return(false); } drawer.BeginSubsection("Collision"); drawer.Field("decelerationThreshold", true, "m/s2"); drawer.Field("collisionTimeout", true, "s"); drawer.ReorderableList("collisionIgnoreTags"); drawer.EndSubsection(); drawer.BeginSubsection("Damage"); drawer.Field("damageIntensity"); if (damageHandler.VehicleController != null) { drawer.Label($"Current Damage: {damageHandler.Damage} ({damageHandler.Damage * 100f}%)"); drawer.Label($"Engine Damage: {damageHandler.VehicleController.powertrain.engine.ComponentDamage}"); drawer.Label( $"Transmission Damage: {damageHandler.VehicleController.powertrain.transmission.ComponentDamage}"); foreach (WheelComponent wheelComponent in damageHandler.VehicleController.Wheels) { drawer.Label($"Wheel {wheelComponent.wheelController.name} Damage: {wheelComponent.Damage}"); } } else { drawer.Info("Damage debug info available in play mode."); } drawer.EndSubsection(); drawer.BeginSubsection("Mesh Deformation"); if (drawer.Field("meshDeform").boolValue) { drawer.Field("deformationVerticesPerFrame"); drawer.Field("deformationRadius", true, "m"); drawer.Field("deformationStrength"); drawer.Field("deformationRandomness"); drawer.ReorderableList("deformationIgnoreTags"); } drawer.EndSubsection(); drawer.BeginSubsection("Actions"); if (drawer.Button("Repair")) { damageHandler.Repair(); } drawer.EndSubsection(); drawer.BeginSubsection("Events"); drawer.Field("OnCollision"); drawer.EndSubsection(); drawer.EndProperty(); return(true); }
public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label) { if (!base.OnNUI(position, property, label)) { return(false); } _transmissionComponent = SerializedPropertyHelper.GetTargetObjectOfProperty(property) as TransmissionComponent; SerializedProperty transmissionType = property.FindPropertyRelative("_transmissionType"); TransmissionComponent.Type type = (TransmissionComponent.Type)transmissionType.enumValueIndex; DrawCommonProperties(); drawer.BeginSubsection("General"); drawer.Field("_transmissionType"); drawer.Field("reverseType"); drawer.EndSubsection(); drawer.BeginSubsection("Gearing"); drawer.Field("finalGearRatio"); drawer.Field("gearingProfile"); drawer.EmbeddedObjectEditor(_transmissionComponent.gearingProfile, drawer.positionRect); if (type == TransmissionComponent.Type.CVT) { drawer.Field("cvtMaxInputTorque"); } drawer.EndSubsection(); if (type != TransmissionComponent.Type.CVT) { drawer.BeginSubsection("Shifting"); drawer.Field("shiftDuration", true, "s"); drawer.Field("postShiftBan", true, "s"); if (type != TransmissionComponent.Type.Manual) { drawer.Field("_upshiftRPM", true, "rpm"); drawer.Field("_downshiftRPM", true, "rpm"); drawer.Field("_currentGearIndex"); if (drawer.Field("variableShiftPoint").boolValue) { drawer.Field("variableShiftIntensity"); drawer.Field("inclineEffectCoeff"); drawer.Info( "High Incline Effect Coefficient values can prevent vehicle from changing gears as it is possible to get the Target Upshift RPM value higher than Rev Limiter RPM value. " + "This is intentional to prevent heavy vehicles from upshifting on steep inclines."); drawer.Field("_targetUpshiftRPM", false, "rpm"); drawer.Field("_targetDownshiftRPM", false, "rpm"); } drawer.EndSubsection(); drawer.BeginSubsection("Shift Conditions"); drawer.Field("shiftCheckCooldown"); drawer.Field("noWheelSpin", false); drawer.Field("noWheelSkid", false); drawer.Field("noWheelAir", false); drawer.Field("clutchEngaged", false); drawer.Field("externalShiftChecksValid", false); drawer.EndSubsection(); } else { drawer.EndSubsection(); } drawer.BeginSubsection("Events"); drawer.Space(2); drawer.Field("onShift"); drawer.Field("onUpshift"); drawer.Field("onDownshift"); drawer.EndSubsection(); } EditorGUI.EndDisabledGroup(); drawer.EndProperty(); return(true); }