public override AbstractGenerator CreateGenerator(GameObject go) { var pos = UITestUtils.CenterPointOfObject(go.GetComponent <RectTransform>()); var anyCamera = GameObject.FindObjectOfType <Camera>(); pos.x = pos.x / anyCamera.pixelWidth; pos.y = pos.y / anyCamera.pixelHeight; return(VoidMethod.Path(go).Float(pos.x).Float(pos.y).Float(pos.x).Float(pos.y).Float(1)); }
public static GameObject FindUIObjectWhichOverlayGivenObject(GameObject overlayedGameObject) { var rtr = overlayedGameObject.GetComponent <RectTransform>(); if (!rtr) { Debug.LogError("rect transform is null for Gameobject: " + UITestUtils.GetGameObjectFullPath(overlayedGameObject)); } var point = UITestUtils.CenterPointOfObject(rtr); GameObject gameObjectUnderClick = UITestUtils.FindObjectByPixels(point.x, point.y); if (gameObjectUnderClick == null || gameObjectUnderClick == overlayedGameObject) { return(null); } GameObject parent = null; if (gameObjectUnderClick.transform.parent) { parent = gameObjectUnderClick.transform.parent.gameObject; } while (parent) { if (parent == overlayedGameObject) { return(null); } if (parent.transform.parent) { parent = parent.transform.parent.gameObject; } else { parent = null; } } return(gameObjectUnderClick); }