public void SpawnVehicle(int vehicle) { newVehicle = Instantiate(vehicles[vehicle], spawnPoint, Quaternion.LookRotation(spawnRot, GlobalControl.worldUpDir)) as GameObject; cam.target = newVehicle.transform; cam.Initialize(); vp = newVehicle.GetComponent<VehicleParent>(); cam.GetComponent<CameraControlls>().cameraTarget = newVehicle.transform; trans = newVehicle.GetComponentInChildren<Transmission>(); if (trans) { trans.automatic = autoShift; newVehicle.GetComponent<VehicleParent>().brakeIsReverse = autoShift; if (trans is GearboxTransmission) { gearbox = trans as GearboxTransmission; } else if (trans is ContinuousTransmission) { varTrans = trans as ContinuousTransmission; if (!autoShift) { vp.brakeIsReverse = true; } } } if (newVehicle.GetComponent<VehicleAssist>()) { newVehicle.GetComponent<VehicleAssist>().enabled = assist; } if (newVehicle.GetComponent<FlipControl>() && newVehicle.GetComponent<StuntDetect>()) { newVehicle.GetComponent<FlipControl>().flipPower = stuntMode && assist ? new Vector3(10, 10, -10) : Vector3.zero; newVehicle.GetComponent<FlipControl>().rotationCorrection = stuntMode ? Vector3.zero : (assist ? new Vector3(5, 1, 10) : Vector3.zero); newVehicle.GetComponent<FlipControl>().stopFlip = assist; stunter = newVehicle.GetComponent<StuntDetect>(); } engine = newVehicle.GetComponentInChildren<Motor>(); propertySetter = newVehicle.GetComponent<PropertyToggleSetter>(); stuntText.gameObject.SetActive(stuntMode); scoreText.gameObject.SetActive(stuntMode); }
void Start() { vp = GetComponent<VehicleParent>(); //Get transmission for using reverse lights if (transmission) { if (transmission is GearboxTransmission) { gearTrans = transmission as GearboxTransmission; } else if (transmission is ContinuousTransmission) { conTrans = transmission as ContinuousTransmission; } } }
public override void OnInspectorGUI() { var boldFoldout = new GUIStyle(EditorStyles.foldout); boldFoldout.fontStyle = FontStyle.Bold; var targetScript = (GearboxTransmission)this.target; var allTargets = new GearboxTransmission[this.targets.Length]; this.isPrefab = PrefabUtility.GetPrefabType(targetScript) == PrefabType.Prefab; for (var i = 0; i < this.targets.Length; i++) { Undo.RecordObject(this.targets[i], "Transmission Change"); allTargets[i] = this.targets[i] as GearboxTransmission; } this.DrawDefaultInspector(); if (!this.isPrefab && targetScript.gameObject.activeInHierarchy) { showButtons = EditorGUILayout.Foldout(showButtons, "Quick Actions", boldFoldout); EditorGUI.indentLevel++; if (showButtons) { if (GUILayout.Button("Calculate RPM Ranges")) { foreach (var curTarget in allTargets) { curTarget.CalculateRpmRanges(); } } } EditorGUI.indentLevel--; } if (GUI.changed) { EditorUtility.SetDirty(targetScript); } }