How to check if GUILayout.Button was clicked?

Hey, sorry if this is an easy one. Is there a way to access the button from a custom editor script which has:

	if (GUILayout.Button("Randomize"))
			Debug.Log("Clicked the Randomizer Button");

Is there a way for another script, to access this button? so when it’s clicked, it will run a line in it’s own script? which is this:

		corkState = (CorkStates)corkValues.GetValue(UnityEngine.Random.Range(0,corkValues.Length));


I have it set to anykeydown right now to test it. but I want to be able to randomize from the inspector with a button.


This is a perfect time to use Events:

You could set a variable indicating the button has been pressed. (Maybe in a public property of the object with the GUI script.

Then in the corkstate script check that value, reset it to false, and do what you need to do.