Greetings,
Anyone know how i can connect my mouseSens Float to my Slider UI which then controlls the mouseSens Value.
So, i have a Slider and 2 Scripts.
1 Script is responsible for the Movement of the Camera (CameraController),
The CameraController has the MouseSens in it.
2 Script is responsible for all the Settings Stuff that are in my Settings Menu.
In it is the Slider and the int SensSlider.
The SensSlider is the int which will get the Value of the Slider and so change the MouseSens via Playerprefs.
Here a Screenshot of my Slider Settings.
Now the Code that is Responsible to do it, but i can’t get it right and don’t know how to.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CameraController : MonoBehaviour
{
float mouseSens;
private void Start()
{
PlayerPrefs.SetFloat("mouseSens", 1000f);
}
private void Update()
{
mouseSens = PlayerPrefs.GetFloat("mouseSens");
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class SettingsMenu : MonoBehaviour
{
public Slider slider;
public int SensSlider;
private void Update()
{
slider.value = value;
PlayerPrefs.GetFloat("mouseSens");
PlayerPrefs.SetFloat("mouseSens", SensSlider);
}
}