diff --git a/Assets/Prefab/Material/Frame_225.png b/Assets/Prefab/Material/Frame_225.png new file mode 100644 index 00000000..eaece96b --- /dev/null +++ b/Assets/Prefab/Material/Frame_225.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c313cba13d45caf9a9336e94a917cddef3b7d4b236d1df91b27b4584f0b523f7 +size 118108 diff --git a/Assets/Prefab/Material/Frame_225.png.meta b/Assets/Prefab/Material/Frame_225.png.meta new file mode 100644 index 00000000..593bdb2e --- /dev/null +++ b/Assets/Prefab/Material/Frame_225.png.meta @@ -0,0 +1,140 @@ +fileFormatVersion: 2 +guid: 5ce6115a8bc839b4ea9627d3727d8946 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 0 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 0 + lightmap: 0 + compressionQuality: 50 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 1 + spriteTessellationDetail: -1 + textureType: 8 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Android + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: 5e97eb03825dee720800000000000000 + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefab/logo.png b/Assets/Prefab/Material/logo.png similarity index 100% rename from Assets/Prefab/logo.png rename to Assets/Prefab/Material/logo.png diff --git a/Assets/Prefab/logo.png.meta b/Assets/Prefab/Material/logo.png.meta similarity index 100% rename from Assets/Prefab/logo.png.meta rename to Assets/Prefab/Material/logo.png.meta diff --git a/Assets/RealisticCarControllerV3/Scripts/RCC_DashboardInputs.cs b/Assets/RealisticCarControllerV3/Scripts/RCC_DashboardInputs.cs index 298fc370..91dc417b 100644 --- a/Assets/RealisticCarControllerV3/Scripts/RCC_DashboardInputs.cs +++ b/Assets/RealisticCarControllerV3/Scripts/RCC_DashboardInputs.cs @@ -1,13 +1,4 @@ -//---------------------------------------------- -// Realistic Car Controller -// -// Copyright © 2014 - 2023 BoneCracker Games -// https://www.bonecrackergames.com -// Buğra Özdoğanlar -// -//---------------------------------------------- - -using UnityEngine; +using UnityEngine; using System.Collections; using System.Collections.Generic; @@ -15,7 +6,8 @@ using System.Collections.Generic; /// Receiving inputs from active vehicle on your scene, and feeds dashboard needles, texts, images. /// [AddComponentMenu("BoneCracker Games/Realistic Car Controller/UI/RCC UI Dashboard Inputs")] -public class RCC_DashboardInputs : MonoBehaviour { +public class RCC_DashboardInputs : MonoBehaviour +{ public RCC_CarControllerV3 vehicle; // Target vehicle. public bool autoAssignVehicle = true; // Auto assign target vehicle as player vehicle from the RCC_SceneManager. diff --git a/Assets/RealisticCarControllerV3/Scripts/RCC_UIDashboardDisplay.cs b/Assets/RealisticCarControllerV3/Scripts/RCC_UIDashboardDisplay.cs index ea3663a3..0cd7e545 100644 --- a/Assets/RealisticCarControllerV3/Scripts/RCC_UIDashboardDisplay.cs +++ b/Assets/RealisticCarControllerV3/Scripts/RCC_UIDashboardDisplay.cs @@ -1,13 +1,4 @@ -//---------------------------------------------- -// Realistic Car Controller -// -// Copyright © 2014 - 2023 BoneCracker Games -// https://www.bonecrackergames.com -// Buğra Özdoğanlar -// -//---------------------------------------------- - -using UnityEngine; +using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.UI; diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 0bdce7d1..f3fde0ad 100644 Binary files a/Assets/Scenes/SampleScene.unity and b/Assets/Scenes/SampleScene.unity differ diff --git a/Assets/Scenes/StartMenu.unity b/Assets/Scenes/StartMenu.unity index 0292c7e3..fe963540 100644 Binary files a/Assets/Scenes/StartMenu.unity and b/Assets/Scenes/StartMenu.unity differ diff --git a/Assets/Scripts/DashboardDisplayPlayer2.cs b/Assets/Scripts/DashboardDisplayPlayer2.cs new file mode 100644 index 00000000..af615468 --- /dev/null +++ b/Assets/Scripts/DashboardDisplayPlayer2.cs @@ -0,0 +1,263 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +using UnityEngine.UI; + +/// +/// Handles RCC Canvas dashboard elements. +/// +[AddComponentMenu("BoneCracker Games/Realistic Car Controller/UI/Dashboard Displayer Player2")] +[RequireComponent(typeof(DashboardInputPlayer2))] +public class DashboardDisplayPlayer2 : MonoBehaviour +{ + + // Inputs of the dashboard elements. + private DashboardInputPlayer2 inputs; + private DashboardInputPlayer2 Inputs + { + + get + { + + if (inputs == null) + inputs = GetComponent(); + + return inputs; + + } + + } + + public DisplayType displayType = DisplayType.Full; // Current display type. + public enum DisplayType { Full, Customization, TopButtonsOnly, Off } + + public RCC_CarControllerV3 vehicle; + public bool autoAssignVehicle = true; + + // Buttons, texts, images, and dropdown menus. + [Header("Panels")] + public GameObject controllerButtons; + public GameObject gauges; + public GameObject customizationMenu; + + [Header("Texts")] + public Text RPMLabel; + public Text KMHLabel; + public Text GearLabel; + public Text recordingLabel; + + [Header("Images")] + //public Image ABS; + //public Image ESP; + //public Image Park; + //public Image Headlights; + //public Image leftIndicator; + //public Image rightIndicator; + //public Image heatIndicator; + //public Image fuelIndicator; + public Image rpmIndicator; + + [Header("Colors")] + public Color color_On = Color.yellow; + public Color color_Off = Color.white; + + [Header("Dropdowns")] + public Dropdown mobileControllersDropdown; + + private void Update() + { + + if (mobileControllersDropdown) + mobileControllersDropdown.interactable = RCC_Settings.Instance.mobileControllerEnabled; + + // Enabling / disabling corresponding elements related to choosen display type. + switch (displayType) + { + + case DisplayType.Full: + + if (controllerButtons && !controllerButtons.activeSelf) + controllerButtons.SetActive(true); + + if (gauges && !gauges.activeSelf) + gauges.SetActive(true); + + if (customizationMenu && customizationMenu.activeSelf) + customizationMenu.SetActive(false); + + break; + + case DisplayType.Customization: + + if (controllerButtons && controllerButtons.activeSelf) + controllerButtons.SetActive(false); + + if (gauges && gauges.activeSelf) + gauges.SetActive(false); + + if (customizationMenu && !customizationMenu.activeSelf) + customizationMenu.SetActive(true); + + break; + + case DisplayType.TopButtonsOnly: + + if (controllerButtons.activeSelf) + controllerButtons.SetActive(false); + + if (gauges.activeSelf) + gauges.SetActive(false); + + if (customizationMenu.activeSelf) + customizationMenu.SetActive(false); + + break; + + case DisplayType.Off: + + if (controllerButtons && controllerButtons.activeSelf) + controllerButtons.SetActive(false); + + if (gauges && gauges.activeSelf) + gauges.SetActive(false); + + if (customizationMenu && customizationMenu.activeSelf) + customizationMenu.SetActive(false); + + break; + + } + + } + + private void LateUpdate() + { + + // If inputs are not enabled yet, disable it and return. + if (!Inputs.enabled) + return; + + if (autoAssignVehicle && RCC_SceneManager.Instance.activePlayerVehicle) + vehicle = RCC_SceneManager.Instance.activePlayerVehicle; + + if (!vehicle) + return; + + if (RPMLabel) + RPMLabel.text = Inputs.RPM.ToString("0"); + + if (KMHLabel) + { + + if (RCC_Settings.Instance.units == RCC_Settings.Units.KMH) + KMHLabel.text = Inputs.KMH.ToString("0") + "\nKMH"; + else + KMHLabel.text = (Inputs.KMH * 0.62f).ToString("0") + "\nMPH"; + + } + + if (GearLabel) + { + + if (!Inputs.NGear && !Inputs.changingGear) + GearLabel.text = Inputs.direction == 1 ? (Inputs.Gear + 1).ToString("0") : "R"; + else + GearLabel.text = "N"; + + } + + if (recordingLabel) + { + + switch (RCC_SceneManager.Instance.recordMode) + { + + case RCC_SceneManager.RecordMode.Neutral: + + if (recordingLabel.gameObject.activeSelf) + recordingLabel.gameObject.SetActive(false); + + recordingLabel.text = ""; + + break; + + case RCC_SceneManager.RecordMode.Play: + + if (!recordingLabel.gameObject.activeSelf) + recordingLabel.gameObject.SetActive(true); + + recordingLabel.text = "Playing"; + recordingLabel.color = Color.green; + + break; + + case RCC_SceneManager.RecordMode.Record: + + if (!recordingLabel.gameObject.activeSelf) + recordingLabel.gameObject.SetActive(true); + + recordingLabel.text = "Recording"; + recordingLabel.color = Color.red; + + break; + + } + + } + + //if (ABS) + // ABS.color = Inputs.ABS == true ? color_On : color_Off; + + //if (ESP) + // ESP.color = Inputs.ESP == true ? color_On : color_Off; + + //if (Park) + // Park.color = Inputs.Park == true ? Color.red : color_Off; + + //if (Headlights) + // Headlights.color = Inputs.Headlights == true ? Color.green : color_Off; + + //if (heatIndicator) + // heatIndicator.color = vehicle.engineHeat >= 100f ? Color.red : new Color(.1f, 0f, 0f); + + //if (fuelIndicator) + // fuelIndicator.color = vehicle.fuelTank < 10f ? Color.red : new Color(.1f, 0f, 0f); + + //if (rpmIndicator) + // rpmIndicator.color = vehicle.engineRPM >= vehicle.maxEngineRPM - 500f ? Color.red : new Color(.1f, 0f, 0f); + + //if (leftIndicator && rightIndicator) { + + // switch (Inputs.indicators) { + + // case RCC_CarControllerV3.IndicatorsOn.Left: + // leftIndicator.color = new Color(1f, .5f, 0f); + // rightIndicator.color = new Color(.5f, .25f, 0f); + // break; + // case RCC_CarControllerV3.IndicatorsOn.Right: + // leftIndicator.color = new Color(.5f, .25f, 0f); + // rightIndicator.color = new Color(1f, .5f, 0f); + // break; + // case RCC_CarControllerV3.IndicatorsOn.All: + // leftIndicator.color = new Color(1f, .5f, 0f); + // rightIndicator.color = new Color(1f, .5f, 0f); + // break; + // case RCC_CarControllerV3.IndicatorsOn.Off: + // leftIndicator.color = new Color(.5f, .25f, 0f); + // rightIndicator.color = new Color(.5f, .25f, 0f); + // break; + + // } + + //} + + } + + public void SetDisplayType(DisplayType _displayType) + { + + displayType = _displayType; + + } + +} diff --git a/Assets/Scripts/DashboardDisplayPlayer2.cs.meta b/Assets/Scripts/DashboardDisplayPlayer2.cs.meta new file mode 100644 index 00000000..a8fc9096 --- /dev/null +++ b/Assets/Scripts/DashboardDisplayPlayer2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4bf3ad1f423536b43ad3dcae666e2b70 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/DashboardInputPlayer2.cs b/Assets/Scripts/DashboardInputPlayer2.cs new file mode 100644 index 00000000..3f57fc19 --- /dev/null +++ b/Assets/Scripts/DashboardInputPlayer2.cs @@ -0,0 +1,221 @@ +using UnityEngine; + +/// +/// Receiving inputs from active vehicle on your scene, and feeds dashboard needles, texts, images. +/// +[AddComponentMenu("BoneCracker Games/Realistic Car Controller/UI/Dashboard Input Player2")] +public class DashboardInputPlayer2 : MonoBehaviour +{ + + public RCC_CarControllerV3 vehiclePlayer2; // Target vehicle. + public bool autoAssignVehicle = true; // Auto assign target vehicle as player vehicle from the RCC_SceneManager. + + // Needles. + [Header("Needles")] + public GameObject RPMNeedle; + public GameObject KMHNeedle; + public GameObject turboGauge; + public GameObject turboNeedle; + public GameObject NOSGauge; + public GameObject NoSNeedle; + public GameObject heatGauge; + public GameObject heatNeedle; + public GameObject fuelGauge; + public GameObject fuelNeedle; + + // Needle rotations. + private float RPMNeedleRotation = 0f; + private float KMHNeedleRotation = 0f; + private float BoostNeedleRotation = 0f; + private float NoSNeedleRotation = 0f; + private float heatNeedleRotation = 0f; + private float fuelNeedleRotation = 0f; + + // Variables of the player vehicle. + [HideInInspector] public float RPM; + [HideInInspector] public float KMH; + [HideInInspector] public int direction = 1; + [HideInInspector] public float Gear; + [HideInInspector] public bool changingGear = false; + [HideInInspector] public bool NGear = false; + [HideInInspector] public bool ABS = false; + [HideInInspector] public bool ESP = false; + [HideInInspector] public bool Park = false; + [HideInInspector] public bool Headlights = false; + [HideInInspector] public RCC_CarControllerV3.IndicatorsOn indicators; + + private void Update() + { + + if (autoAssignVehicle && RCC_SceneManager.Instance.activePlayerVehicle) + vehiclePlayer2 = RCC_SceneManager.Instance.activePlayerVehicle; + else + vehiclePlayer2 = null; + + // If no any player vehicle, return. + if (!vehiclePlayer2) + return; + + // If player vehicle is not controllable or controlled by AI, return. + if (!vehiclePlayer2.canControl || vehiclePlayer2.externalController) + return; + + // If nos gauge is selected, enable or disable gauge related to vehicle. + if (NOSGauge) + { + + if (vehiclePlayer2.useNOS) + { + + if (!NOSGauge.activeSelf) + NOSGauge.SetActive(true); + + } + else + { + + if (NOSGauge.activeSelf) + NOSGauge.SetActive(false); + + } + + } + + // If turbo gauge is selected, enable or disable turbo gauge related to vehicle. + if (turboGauge) + { + + if (vehiclePlayer2.useTurbo) + { + + if (!turboGauge.activeSelf) + turboGauge.SetActive(true); + + } + else + { + + if (turboGauge.activeSelf) + turboGauge.SetActive(false); + + } + + } + + // If heat gauge is selected, enable or disable heat gauge related to vehicle. + if (heatGauge) + { + + if (vehiclePlayer2.useEngineHeat) + { + + if (!heatGauge.activeSelf) + heatGauge.SetActive(true); + + } + else + { + + if (heatGauge.activeSelf) + heatGauge.SetActive(false); + + } + + } + + // If fuel gauge is selected, enable or disable fuel gauge related to vehicle. + if (fuelGauge) + { + + if (vehiclePlayer2.useFuelConsumption) + { + + if (!fuelGauge.activeSelf) + fuelGauge.SetActive(true); + + } + else + { + + if (fuelGauge.activeSelf) + fuelGauge.SetActive(false); + + } + + } + + // Getting variables from the player vehicle. + RPM = vehiclePlayer2.engineRPM; + KMH = vehiclePlayer2.speed; + direction = vehiclePlayer2.direction; + Gear = vehiclePlayer2.currentGear; + changingGear = vehiclePlayer2.changingGear; + NGear = vehiclePlayer2.NGear; + ABS = vehiclePlayer2.ABSAct; + ESP = vehiclePlayer2.ESPAct; + Park = vehiclePlayer2.handbrakeInput > .1f ? true : false; + Headlights = vehiclePlayer2.lowBeamHeadLightsOn || vehiclePlayer2.highBeamHeadLightsOn; + indicators = vehiclePlayer2.indicatorsOn; + + // If RPM needle is selected, assign rotation of the needle. + if (RPMNeedle) + { + + RPMNeedleRotation = (vehiclePlayer2.engineRPM / 50f); + RPMNeedleRotation = Mathf.Clamp(RPMNeedleRotation, 0f, 180f); + RPMNeedle.transform.eulerAngles = new Vector3(RPMNeedle.transform.eulerAngles.x, RPMNeedle.transform.eulerAngles.y, -RPMNeedleRotation); + + } + + // If KMH needle is selected, assign rotation of the needle. + if (KMHNeedle) + { + + if (RCC_Settings.Instance.units == RCC_Settings.Units.KMH) + KMHNeedleRotation = (vehiclePlayer2.speed); + else + KMHNeedleRotation = (vehiclePlayer2.speed * 0.62f); + + KMHNeedle.transform.eulerAngles = new Vector3(KMHNeedle.transform.eulerAngles.x, KMHNeedle.transform.eulerAngles.y, -KMHNeedleRotation); + + } + + // If turbo needle is selected, assign rotation of the needle. + if (turboNeedle) + { + + BoostNeedleRotation = (vehiclePlayer2.turboBoost / 30f) * 270f; + turboNeedle.transform.eulerAngles = new Vector3(turboNeedle.transform.eulerAngles.x, turboNeedle.transform.eulerAngles.y, -BoostNeedleRotation); + + } + + // If nos needle is selected, assign rotation of the needle. + if (NoSNeedle) + { + + NoSNeedleRotation = (vehiclePlayer2.NoS / 100f) * 270f; + NoSNeedle.transform.eulerAngles = new Vector3(NoSNeedle.transform.eulerAngles.x, NoSNeedle.transform.eulerAngles.y, -NoSNeedleRotation); + + } + + // If heat needle is selected, assign rotation of the needle. + if (heatNeedle) + { + + heatNeedleRotation = (vehiclePlayer2.engineHeat / 110f) * 270f; + heatNeedle.transform.eulerAngles = new Vector3(heatNeedle.transform.eulerAngles.x, heatNeedle.transform.eulerAngles.y, -heatNeedleRotation); + + } + + // If fuel needle is selected, assign rotation of the needle. + if (fuelNeedle) + { + + fuelNeedleRotation = (vehiclePlayer2.fuelTank / vehiclePlayer2.fuelTankCapacity) * 270f; + fuelNeedle.transform.eulerAngles = new Vector3(fuelNeedle.transform.eulerAngles.x, fuelNeedle.transform.eulerAngles.y, -fuelNeedleRotation); + + } + + } + +} diff --git a/Assets/Scripts/DashboardInputPlayer2.cs.meta b/Assets/Scripts/DashboardInputPlayer2.cs.meta new file mode 100644 index 00000000..28572bc5 --- /dev/null +++ b/Assets/Scripts/DashboardInputPlayer2.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c0567eca99e97144f9dfbacaa29d1c58 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset b/Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset index 15ced898..78b42fb4 100644 Binary files a/Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset and b/Assets/TextMesh Pro/Resources/Fonts & Materials/LiberationSans SDF - Fallback.asset differ