Hello, I am right now trying to build an EditorWindow from which I can activate my boosters, it works very simple, if I click the button on the EditorWindow the bool gets set too true.
Now I want to pass the bool variable to my playerMovement script, a MonoBehaviour script normally I would just reference the script where I set the bool variable, but I can not attach the editor window script to the playerMovement script, after some time googling I saw that you can’t reference an EditorWindow script inside a MonoBehaviour script.
So how I do pass a bool variable from the EditorWindow to the PlayerMovement script?
My EditorWindow looks like this:
public bool speedBooster;
[MenuItem("My Windows/BoosterWindow")]
static void Init()
{
boosterWindow window = (boosterWindow)EditorWindow.GetWindow(typeof(boosterWindow));
window.Show();
}
void OnGUI()
{
GUILayout.Label("Active the boosters from the buttons below");
if (GUILayout.Button("SpeedBooster"))
{
speedBooster = true;
}
}
And my playerMovement will use the variable like this:
public class PlayerMovement : MonoBehaviour
{
public boosterWindow bw;
private void Update()
{
if (bw.speedBooster)
{
boosting = true;
speed -= 5;
}
}
}
Can anybody suggest me an idea of how I can tell the playerMovement script that the bool is true so that the speed variable gets changed?