I'm developing an Unity app which can use bookmark buttons open multiple internal browser windows. For now, I make the browser Prefab, and instantiate it for open multiples simultaneously. But the windows will overlay together, users won't know if it was opened a new window, or redirect in the existed window, unless they drag one away.
I tried a `for' loop to open multiple windows, but all the windows in the for loop count come out by one click, same url. Luckily, in the desired offset positions I want.
But it should be one click open a new window, another click open a new window offset to the previous one.
Here is my bookmark button script:
// Open the browser window instance with bookmark button
public void OpenLinks(string link)
{
for (int i = 0; i<=10; i++)
{
GameObject browser = Instantiate(browserWindow, new Vector2(i * 50 + 50, -(i * 50) - 50), browserWindow.transform.rotation);
browser.SetActive(true);
browser.GetComponent<SimpleWebBrowser.WebBrowser2D>().Navigate(link);
browser.transform.parent = Windows.transform;
browser.name = "Page - " + link;
}
}
I assume that maybe there needs an if statement rather than for loop. But I don't know how to. because I need to keep the instantiate in the OpenLinks(), so that I can destroy the instances later to release the memory, and reopen again.
Can anyone help me?

It looks like what you want to do is open a single window at a time, and store that window instance. Each window is then opened in the next position, so you need to store the value where the next window needs to open, either by storing the last position, or the next. In the example code below, we store where the window should open next.
There's a lot of extra code that will need to go in, such as what happens when the next window to open is off the screen and really needs to code back around to the top of the screen again, but we'll leave that for now with just a quick check for hard coded positions.
With that being said, here's a an example piece of code that should do what you're looking for: