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?