예제 #1
0
    public void OnPointerClick(PointerEventData p)
    {
        RectTransform rectTransform = GetComponent <RectTransform>();

        minimapUIActualWdithAndHeight = new Vector2(rectTransform.sizeDelta.x * rectTransform.localScale.x, rectTransform.sizeDelta.y * rectTransform.localScale.y);
        minimapUIRightUpPos           = new Vector2(rectTransform.position.x, rectTransform.position.y);

        scaleXY = new Vector2(rectTransform.position.x / (rectTransform.localPosition.x * 2), rectTransform.position.y / (rectTransform.localPosition.y * 2));

        screenPosInMiniMapCamera = new Vector2(1.0f - (rectTransform.position.x - p.position.x) / (minimapUIActualWdithAndHeight.x * scaleXY.x), 1.0f - (rectTransform.position.y - p.position.y) / (minimapUIActualWdithAndHeight.y * scaleXY.y));

//        Debug.Log("右上角实际位置:" + rectTransform.position);
//        Debug.Log("缩放值:"+scaleXY);
//        Debug.Log("鼠标点击位置:"+p.position);
//        Debug.Log("左下角实际位置:" + new Vector2(rectTransform.position.x-minimapUIActualWdithAndHeight.x*scaleXY.x, rectTransform.position.y - minimapUIActualWdithAndHeight.y * scaleXY.y));
//        Debug.Log("screenPosInMiniMapCamera:" + screenPosInMiniMapCamera);

        ray = miniMapCamera.GetComponent <Camera>().ViewportPointToRay(new Vector3(screenPosInMiniMapCamera.x, screenPosInMiniMapCamera.y, 0.0f));

        Debug.DrawLine(ray.origin, ray.origin + ray.direction * 1000);

        if (Physics.Raycast(ray, out hit, 1000))
        {
            Debug.Log(hit.collider.name);

            ColliderTriggerButton c = hit.transform.GetComponent <ColliderTriggerButton>();
            ColliderTriggerButton.touchRayCastFrom = ColliderTriggerButton.TouchRayCastFrom.Minimap;
            if (c != null)
            {
                c.ExeTriggerEvent(null);
            }
        }
    }
예제 #2
0
 public void SetDefaultCubemap()
 {
     colliderTriggerRoot.gameObject.SetActive(true);
     ColliderTriggerButton.touchRayCastFrom = ColliderTriggerButton.TouchRayCastFrom.Minimap;
     if (defaultColliderTriggerButton != null)
     {
         defaultColliderTriggerButton.ExeTriggerEvent(null);
     }
 }