Good day,
I need criticism/suggestions on a suitable way of controlling many states of display in a GUI like method, "GUIMethod", below.
Edited: Three scripts in question A,B,C. C is enabled. Once we click a button (produced by C) we disable C and enable B. A and B toggle each other based on clicking events.
/*
*Script 1
*/
public class Script_1 {
private enum ScriptOneStates {
A, B, C, D, E, //...
}
private ScriptOneStates states;
private GUIMethod() {
switch (states) {
case ScriptOneStates.A:
Method1_A();
Method2_A();
break;
case ScriptOneStates.B:
Method1_B();
Method2_B();
break;
}
}
private void Method1_B() {
if (InputManager.Button("Forward")) {
GetComponent<Script_1>.isEnabled = true;
GetComponent<Script_2>.isEnabled = false;
}
}
}
/*
*Script 2
*/
public class Script_2 {
private enum ScriptTwoStates {
A, B, C, D, E, //...
}
private ScriptTwoStates states;
private GUIMethod() {
switch (states) {
case ScriptTwoStates.A:
Method1_A();
Method2_A();
break;
case ScriptOneStates.B:
Method1_B();
Method2_B();
break;
}
}
private void Method1_B() {
if (InputManager.Button("Back")) {
GetComponent<Script_2>.isEnabled = false;
GetComponent<Script_1>.isEnabled = true;
}
}
}
The type 'GetComponent' is a global reference to access scripting components. Given that this is okay, I would like to know if this is acceptable.
