/// <summary> /// Sets the index of the car. /// </summary> /// <param name="index">The index of the car in the race.</param> public void SetIndex(int index) { this.Index = index; // Set car color and customization based on saved data CarCustomization customization = SavedDataManager.Data.CarCustomizations[index]; Material frontMaterial = this.chassisFront.GetComponent <Renderer>().material; frontMaterial.color = customization.FrontColor.Color; frontMaterial.SetFloat("_Metallic", customization.IsFrontShiny ? 1 : 0); Material backMaterial = this.chassisBack.GetComponent <Renderer>().material; backMaterial.color = customization.BackColor.Color; backMaterial.SetFloat("_Metallic", customization.IsBackShiny ? 1 : 0); }
/// <summary> /// Update the customization interface with the current saved data. /// </summary> private void LoadColors() { // TODO: 3 is a magic number for (int i = 0; i < 3; i++) { CarCustomization customization = SavedDataManager.Data.CarCustomizations[i]; this.sliders[6 * i].value = customization.FrontColor.r; this.sliders[6 * i + 1].value = customization.FrontColor.g; this.sliders[6 * i + 2].value = customization.FrontColor.b; this.sliders[6 * i + 3].value = customization.BackColor.r; this.sliders[6 * i + 4].value = customization.BackColor.g; this.sliders[6 * i + 5].value = customization.BackColor.b; this.toggles[(int)Toggles.FirstShiny + 2 * i].isOn = customization.IsFrontShiny; this.toggles[(int)Toggles.FirstShiny + 2 * i + 1].isOn = customization.IsBackShiny; } }