I have multi-numbers browser windows in the Unity app, the newly opened window will popup to the front.
I want to call the clicked window to the front, so I attached a Hierarchy
script.
public class Hierarchy : MonoBehaviour, IPointerDownHandler
{
[SerializeField] private RectTransform topWindow;
// Set clicked object to top
void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
{
// Print debug message to the console
Debug.Log("Object clicked: " + eventData.pointerCurrentRaycast.gameObject.name);
topWindow.SetAsLastSibling();
}
}
But windows only response to the front when it's title bar be clicked, click else where doesn't work. I checked it only detect click event when the title bar be clicked, but not detected click event when click browser area.
Here is the hierarchy in the Prefab, BrowserWindow is the entire are of the window. BrowserBackground is the dark background wraps browser. Browser2D is the Prefab for rendering browser. ControlButtons is the title bar include the page name, close button and detail button.
Anyone can figure out what is this problem comes from?
Try turning off the Raycast Target of an Image
that is not related to a click event.
Image
and Collider
.If it does not work, it may work better if you use a click-only transparent Image
for the foremost side.
BTW: Transparent images are heavy. You can solve this problem by turning off "Cull Transparent Mesh".