void Start() { material = GetComponent <SkinnedMeshRenderer>().material; if (FindObjectOfType <ColorsSettings>() != null) { ColorsSettings colorsSettings = FindObjectOfType <ColorsSettings>(); SetColor(colorsSettings); } }
void SetColor(ColorsSettings _colorsSettings) { if (colorIndex == 0) { material.color = _colorsSettings.PrimaryColor; } else if (colorIndex == 1) { material.color = _colorsSettings.SecondaryColor; } }
void SetColor(ColorsSettings _colorsSettings) { foreach (ChangeMaterialColor color in colors) { if (color.colorIndex == 0) { _colorsSettings.PrimaryColor = color.GetColor(); } else if (color.colorIndex == 1) { _colorsSettings.SecondaryColor = color.GetColor(); } } }
public void SaveColors() { if (FindObjectOfType <ColorsSettings>() != null) { ColorsSettings colorsSettings = FindObjectOfType <ColorsSettings>(); SetColor(colorsSettings); } else { ColorsSettings colorsSettings = Instantiate(colorsSettingsPrefab); SetColor(colorsSettings); } }
/// <summary> /// Set colors settings. /// </summary> /// <param name="colorsSettings">The new colors settings.</param> /// <param name="save">If true, this change will be saved.</param> public static void SetColors(ColorsSettings colorsSettings, bool save = true) { Global.userData.settings.colors = colorsSettings; EventsManager.Call_ColorsSettingsChanged(colorsSettings); EventsManager.Call_ColorChanged(ColorTarget.NormalHomeworks, colorsSettings.NormalHomeworksColor); EventsManager.Call_ColorChanged(ColorTarget.Tests, colorsSettings.TestsColor); EventsManager.Call_ColorChanged(ColorTarget.subjects, colorsSettings.SubjectsColor); EventsManager.Call_ColorChanged(ColorTarget.HighlightedHomeworks, colorsSettings.HighlightColor); EventsManager.Call_WinBackgroundChanged(colorsSettings.BackgroundColor); HomeworkManager.RecolorViewers(); if (save) { Save.SaveData(); } }
void LoadColors() { if (FindObjectOfType <ColorsSettings>() != null) { ColorsSettings colorsSettings = FindObjectOfType <ColorsSettings>(); foreach (ChangeMaterialColor color in colors) { if (color.colorIndex == 0) { color.SetColor(colorsSettings.PrimaryColor); } else if (color.colorIndex == 1) { color.SetColor(colorsSettings.SecondaryColor); } } } }
/// <summary> /// Invoke ColorsSettingsChanged event /// </summary> /// <param name="newColors">New colors settings</param> internal static void Call_ColorsSettingsChanged(ColorsSettings newColors) { ColorsSettingsChanged?.Invoke(newColors); }