- Home /
Question by
AshwinTheGammer · Jun 29, 2021 at 07:36 AM ·
mousecomponentpause menuenable and disable script
How to change value of var of a disabled component?
I've made a pause system. I'm disabling the MouseController script when game get paused. The MouseController script is on two GOs, "GO1" and "GO2(which is parent of GO1)". The SensitivityX of GO1 is 2 and SenstivityY is 0, and of GO2 SenstivityX is 0 and SenstivityY is 2.. How can I change these value using Slider? It just shows 0. Here is the code.
public class MenuController : MonoBehaviour
{
... //Some long codes
if(gamePaused){
mouseControllers[1].enabled = false;
mouseControllers[0].enabled = false;
} else{
mouseControllers[1].enabled = true;
mouseControllers[0].enabled = true;
}}
This is pauseMenu.cs which will be active during game paused:
public class PauseCanvas : MonoBehaviour
{
void Start(){
mouseControllerInScene = FindObjectsOfType<MouseController>();
SenstivitySlider.value = ThirtySec.PlayerPrefs.GetFloat("Senstivity");
}
public void Change_Sensitivity_Slider(){
Sensitivity_Text.text = Mathf.RoundToInt(SenstivitySlider.value * 100) + " %"; //Show the value changed in %
}
}
Since the components are disable it doesnt seem to be changing values.
Comment