I am developing an AR Measuring tool where I'm placing my measuring point disk on the AR Plane. I have added an Undo and Redo button for this, as there is a chance one removes the last placed point using undo button.
Now my issue is that, when I click the undo button, the point disk gets placed behind the button and the Undo buttons for that place only. Same goes for the Redo button. If there is no value for Redo to respawn, the object gets spawned behind the redo button as if I was instantiating the point disk behind the button, which I am not doing.
It will be helpful if someone can give me an idea on how to make sure that I spawn an object but not when I clicked on button. Yet the button does the work it has been assigned.
I have taken two videos as reference and merged the code in that.
For the Undo-Redo Buttons Link using Command Design Pattern
For the line render between the object placement without AR Placement Interactable
Instead of AR Interactable, I used the code of Undo-Redo.
And I have used this method too for removing the spawning code over the button but then the button doesn't work at all.
public void UndoCommands()
{
if (Input.touchCount > 0)
{
Touch touch = Input.GetTouch(0);
if (undoHistoryStack.Count > 0 && !EventSystem.current.IsPointerOverGameObject(touch.fingerId))
{
//Code that is going to work when this function is called
}
}
}
This code will be added to Undo Button, and similarly goes for the Redo.
I have been trying to crack this situation for so long. If any other details are required, I will try my best to share. But, please help me out here.