I have a gameobject that uses accelerometer as control input and also touch input. Now the game would be very bad if both controls are active at the same time, so I need to disable and enable controls by a toggle but sadly, the toggle is in settings menu, while the gameobject is in the game/play, so to summarize this:
1 - Disable/Toggle Accelerometer and Touch
2 - Access GameObject from another scene
3 - How to save the state of the toggle(including the state of the controls)
Thank You
Your steps are wrong.
Just in setting menu save your variable to PlayerPref:
PlayerPrefs.SetInt("ControlMode", 0)); //Accelerometer
PlayerPrefs.SetInt("ControlMode", 1)); //Touch
In the other scene you read this value and just set in your control script a condition or similar over "ControlMode":
int currentMode = PlayerPrefs.GetInt("ControlMode");
if (currentMode == 0)
{
//Accelerometer input control
}
else
{
//Touch input control
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments