105 lines
2.8 KiB
C#
105 lines
2.8 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
using UnityEngine.Events;
|
||
|
using UnityEngine.Audio;
|
||
|
using TMPro;
|
||
|
|
||
|
public class MenuSettings : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private TMP_InputField mouseInput;
|
||
|
[SerializeField] private Slider mouseSlider;
|
||
|
|
||
|
[SerializeField] private TMP_Text volumeInput;
|
||
|
[SerializeField] private Slider volumeSlider;
|
||
|
|
||
|
public TMP_InputField inputR, inputG, inputB;
|
||
|
public Image gunColorImage;
|
||
|
private float _R, _G, _B;
|
||
|
private Color _gunColor;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
volumeSlider.value = PlayerPrefs.GetFloat("Volume");
|
||
|
|
||
|
mouseInput.text = PlayerPrefs.GetFloat("Sensitivity").ToString("N2");
|
||
|
mouseSlider.value = PlayerPrefs.GetFloat("Sensitivity");
|
||
|
|
||
|
volumeInput.text = PlayerPrefs.GetFloat("Volume").ToString("N2");
|
||
|
|
||
|
if (!PlayerPrefs.HasKey("GunColorR"))
|
||
|
{
|
||
|
PlayerPrefs.SetFloat("GunColorR", 6f / 255);
|
||
|
PlayerPrefs.SetFloat("GunColorG", 14f / 255);
|
||
|
PlayerPrefs.SetFloat("GunColorB", 243f / 255);
|
||
|
}
|
||
|
|
||
|
inputR.text = (PlayerPrefs.GetFloat("GunColorR") * 255).ToString();
|
||
|
inputG.text = (PlayerPrefs.GetFloat("GunColorG") * 255).ToString();
|
||
|
inputB.text = (PlayerPrefs.GetFloat("GunColorB") * 255).ToString();
|
||
|
|
||
|
_R = PlayerPrefs.GetFloat("GunColorR");
|
||
|
_G = PlayerPrefs.GetFloat("GunColorG");
|
||
|
_B = PlayerPrefs.GetFloat("GunColorB");
|
||
|
|
||
|
SetMenuGunColor();
|
||
|
}
|
||
|
|
||
|
public void SetSensitivity(string sensitivity)
|
||
|
{
|
||
|
SetSensitivity(float.Parse(sensitivity));
|
||
|
}
|
||
|
|
||
|
public void SetSensitivity(float sensitivity)
|
||
|
{
|
||
|
mouseSlider.value = sensitivity;
|
||
|
mouseInput.text = sensitivity.ToString("N2");
|
||
|
Settings.instance.SetSensitivity(sensitivity);
|
||
|
}
|
||
|
|
||
|
public void SetVolume(string volume)
|
||
|
{
|
||
|
SetVolume(float.Parse(volume));
|
||
|
}
|
||
|
|
||
|
public void SetVolume(float volume)
|
||
|
{
|
||
|
volumeSlider.value = volume;
|
||
|
volumeInput.text = volume.ToString("N2");
|
||
|
|
||
|
Settings.instance.SetVolume(volume);
|
||
|
}
|
||
|
|
||
|
public void SetColorR(string str)
|
||
|
{
|
||
|
float value = float.Parse(str) / 255;
|
||
|
PlayerPrefs.SetFloat("GunColorR", value);
|
||
|
_R = value;
|
||
|
SetMenuGunColor();
|
||
|
}
|
||
|
|
||
|
public void SetColorG(string str)
|
||
|
{
|
||
|
float value = float.Parse(str) / 255;
|
||
|
PlayerPrefs.SetFloat("GunColorG", value);
|
||
|
_G = value;
|
||
|
SetMenuGunColor();
|
||
|
}
|
||
|
|
||
|
public void SetColorB(string str)
|
||
|
{
|
||
|
float value = float.Parse(str) / 255;
|
||
|
PlayerPrefs.SetFloat("GunColorB", value);
|
||
|
_B = value;
|
||
|
SetMenuGunColor();
|
||
|
}
|
||
|
|
||
|
private void SetMenuGunColor()
|
||
|
{
|
||
|
_gunColor = new Color(_R, _G, _B);
|
||
|
gunColorImage.color = _gunColor;
|
||
|
}
|
||
|
|
||
|
}
|