Can you make a gizmo that changes behavior when clicked?

I’m making some waypoints with gizmos, and I’d like to make the simple gizmos that show the waypoints in the editor work in such a way that if you click on one, it changes from displaying a wire sphere to a wire cube, stays that way, and then if you click on it again, it will turn back to a sphere. So like a gizmo that toggles its shape each time you click on it (not to be confused with a gizmo that changes shape when selected; I know that can be done with OnDrawGizmosSelected).

Can this be done, or is there not enough input recognition in the editor to support such dynamic waypoints?

So, I figured out a kinda cludgey solution. It’s not ideal (an ideal solution would have something where you could test for a mouse click, since now you have to select something else and then re-select the gizmo), but it works! In case someone else needs it, here’s the code, with comments:

using UnityEngine;
public class MovePoint : MonoBehaviour {

public bool isStop = false;
public int clickedCounter = 0;

void OnDrawGizmos(){

    // Semi-transparent color
	Gizmos.color=new Color(1f,0,1f,.5f);
	if (isStop == true){
		Gizmos.DrawCube(transform.position, new Vector3(.5f,.5f,.5f));
	// If the clickedCounter is above 0, try to bring it down to zero
	// If it's currently selected, the OnDrawGizmosSelected function
            // will pull it back up
	if (clickedCounter > 0){

void OnDrawGizmosSelected(){
	// If clickedCounter is zero,
            // it means we just clicked on it; otherwise this function
	// will have pulled the value up
	if (clickedCounter == 0)
		isStop = !isStop;
	// And set the counter to some value, so next cycle,
            // it won't be zero if it was selected last time
	clickedCounter = 5;
	// Finally, draw a bright box to highlight the selected gizmo
	Gizmos.color = Color.cyan;
	Gizmos.DrawWireCube(transform.position, new (.6f,.6f,.6f) );


bool GetIsStop(){
	return isStop;

void SetIsStop(bool x){
	isStop = x;