It sounds to me what you actually want is alternate between the callbacks and each click only execute one of them.
If you have only two of them you could simply use a bool
flag and do
private bool isSecondClick;
void Start()
{
// Use a wrapper callback instead
someUIButtonReference.onClick.AddListener(HandleClick);
}
private void HandleClick()
{
if(!isSecondClick)
{
SomeFunction1();
}
else
{
SomeFunction2();
}
isSecondClick = !isSecondClick;
}
void SomeFunction1()
{
Debug.Log("SomeFunction1");
}
void SomeFunction2()
{
Debug.Log("SomeFunction2");
}
If there are going to be more callbacks then you could rather use something like e.g.
private int index;
private Action[] listeners = new Action[]
{
SomeFunction1,
SomeFunction2,
SomeFunction3,
...
};
void Start()
{
// Use a wrapper callback instead
someUIButtonReference.onClick.AddListener(HandleClick);
}
private void HandleClick()
{
var action = listeners[index];
action.Invoke();
index = (index + 1) % listeners.Length;
}
void SomeFunction1()
{
Debug.Log("SomeFunction1");
}
void SomeFunction2()
{
Debug.Log("SomeFunction2");
}
void SomeFunction3()
{
Debug.Log("SomeFunction3");
}
...