/// <summary> /// Resets the vehicle to default state. /// Sets default values for all fields and assign default objects from resources folder. /// </summary> public void SetDefaults() { steering.SetDefaults(this); powertrain.SetDefaults(this); soundManager.SetDefaults(this); effectsManager.SetDefaults(this); damageHandler.SetDefaults(this); brakes.SetDefaults(this); groundDetection.SetDefaults(this); moduleManager.SetDefaults(this); if (stateSettings == null) { stateSettings = Resources.Load(DEFAULT_RESOURCES_PATH + "DefaultStateSettings") as StateSettings; } if (physicsMaterial == null) { physicsMaterial = Resources.Load(DEFAULT_RESOURCES_PATH + "VehicleMaterial") as PhysicMaterial; } centerOfMass = CaclulateCenterOfMass(); inertiaTensor = CalculateInertiaTensor(); }
public override bool OnInspectorNUI() { if (!base.OnInspectorNUI()) { return false; } StateSettings stateSettings = target as StateSettings; drawer.BeginSubsection("LODs"); drawer.Info("LODs must be ordered from lowest to highest distance."); drawer.ReorderableList("LODs", "LODs"); drawer.EndSubsection(); drawer.BeginSubsection("Component State Definitions"); drawer.Info( "VehicleComponent state definitions are fetched on Awake() and any changes made to them will only " + "affect vehicles initialized after the change was made.", MessageType.Warning); DrawDefinitionsList(stateSettings); drawer.EndSubsection(); drawer.EndEditor(); return true; }
public override bool OnNUI(Rect position, SerializedProperty property, GUIContent label) { drawer.BeginProperty(position, property, label); // Draw label string fullName = drawer.FindProperty("fullName").stringValue.Replace("NWH.VehiclePhysics.", ""); string shortName = fullName.Split('.').Last(); GUIStyle miniStyle = EditorStyles.centeredGreyMiniLabel; miniStyle.alignment = TextAnchor.MiddleLeft; Rect labelRect = drawer.positionRect; labelRect.x += 5f; Rect miniRect = drawer.positionRect; miniRect.x += 200f; EditorGUI.LabelField(labelRect, shortName, EditorStyles.boldLabel); EditorGUI.LabelField(miniRect, fullName, miniStyle); drawer.Space(NUISettings.FIELD_HEIGHT); StateSettings stateSettings = SerializedPropertyHelper.GetTargetObjectWithProperty(property) as StateSettings; if (stateSettings == null) { drawer.EndProperty(); return(false); } ComponentNUIPropertyDrawer.DrawStateSettingsBar ( position, stateSettings.LODs.Count, property.FindPropertyRelative("isOn"), property.FindPropertyRelative("isEnabled"), property.FindPropertyRelative("lodIndex") ); drawer.EndProperty(); return(true); }
private void DrawDefinitionsList(StateSettings stateSettings) { drawer.Label("Vehicle Components:"); int n = stateSettings.definitions.Count; SerializedProperty listProperty = drawer.FindProperty("definitions"); for (int i = 0; i < n; i++) { SerializedProperty element = listProperty.GetArrayElementAtIndex(i); drawer.Property(element); } drawer.Space(10); if (drawer.Button("Refresh")) { stateSettings.Reload(); } }