Exemple #1
0
    public override void Process()
    {
        // Converting the 3D-coords to Canvas-coords (it is giving wrong results, how to do this??)
        Vector3 screenPos = mouseCursor.GetComponent <RectTransform>().position;
        List <RaycastResult> rayResults = new List <RaycastResult>();

        // float scaleFactorX = 1280.0f / Screen.width;
        // float scaleFactorY = 720.0f / Screen.height;
        //float scaleFactorX = canvasScaler.referenceResolution.x / Screen.width;
        //float scaleFactorY = canvasScaler.referenceResolution.y / Screen.height;

        // Raycasting
        PointerEventData pointer = new PointerEventData(eventSystem);

        pointer.position = screenPos;
        pointer.delta    = screenPos - lastPos;

        eventSystem.RaycastAll(pointer, m_RaycastResultCache);
        var raycast = FindFirstRaycast(m_RaycastResultCache);

        pointer.pointerCurrentRaycast = raycast;
        m_RaycastResultCache.Clear();

        lastPos = screenPos;

        ProcessMove(pointer);
    }