I simplify the situation as much as I can:
class 1:
public class GameFlowManager {
public float worldSpeed;
}
class 2:
public class Clouds {
void MoveClouds(float worldSpeed){...}
I need to access worldSpeedfrom Clouds.
Which method is more effective?
- Using
GameFlowManager gfm = FindObjectOfType<GameFlowManager>()
then accessing the variable with a pointer (I know this is not a pointer, but the goal is the same)
gfm.worldSpeed - Or should I use an event that calls the setter function on the classes that need it
worldSpeed? That way I would not need the public variable.
Now it is only for unity, when I cannot use properties. In simple C # code, I can use getters without any consequences, right?