コード例 #1
0
 public void UpdateVolume(string data)
 {
     volume.VolumeData   = data;
     startShowVolumeTime = 0.0f;
     if (PUI_UnityAPI.GetDeviceMode() != DeviceMode.FalconCV2)
     {
         UpdateVolumeUI();
     }
 }
コード例 #2
0
 /// <summary>
 /// 当前设备
 /// </summary>
 private void GetDeviceInfo()
 {
     currentDevice = PUI_UnityAPI.GetDeviceMode();
 }
コード例 #3
0
    public override void Raycast(PointerEventData eventData, List <RaycastResult> resultAppendList)
    {
        if (canvas == null)
        {
            Debug.LogError("PvrGraphicRaycaster requires that the game object  needs 'Canvas' componet !");
            return /*false*/;
        }

        if (eventCamera == null)
        {
            Debug.LogError("PvrGraphicRaycaster requires that the eventCamera is not null");
            return;
        }

        if (canvas.renderMode != RenderMode.WorldSpace)
        {
            Debug.LogError("PvrGraphicRaycaster requires that the canvas renderMode is set to WorldSpace.");
            return /*false*/;
        }


        Ray ray = PvrInputMoudle.ray;

        if (!PUI_UnityAPI.isControllerConnected())
        {
            ray = new Ray(eventCamera.transform.position, eventCamera.transform.forward);
            PvrInputMoudle.ray = ray;
        }
        PvrInputMoudle.FindInputModule().Impl.RayDirection = ray.direction;

        float dist = 20f;

        MaxPointerEndPoint = ray.GetPoint(dist);

        Debug.DrawLine(ray.origin, ray.origin + (ray.direction * 5F), Color.red);
        float hitDistance = float.MaxValue;

        if (blockingObjects != BlockingObjects.None)   /**标记为 None 标签的不需要处理*/
        {
            if (blockingObjects == BlockingObjects.ThreeD || blockingObjects == BlockingObjects.All)
            {
                RaycastHit hit;
                if (Physics.Raycast(ray, out hit, dist, m_BlockingMask))
                {
                    hitDistance = hit.distance;
                    //Debug.Log("Hit postition : " + hit.point);
                    //Debug.Log("ditance : " + Vector3.Distance(hit.point, ray.origin) + "    Hitdistance : " + hitDistance);
                }
            }

            if (blockingObjects == BlockingObjects.TwoD || blockingObjects == BlockingObjects.All)
            {
                RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, dist, m_BlockingMask);
                if (hit.collider != null)
                {
                    hitDistance = hit.fraction * dist;
                }
            }
        }

        m_RaycastResults.Clear();
        Raycast(canvas, ray, eventCamera, dist, m_RaycastResults);

        //Debug.Log("RaycastResult 数量 : " + m_RaycastResults.Count);

        for (var index = 0; index < m_RaycastResults.Count; index++)
        {
            //Debug.Log("RaycastResult 数量 : " + m_RaycastResults.Count + " name "+m_RaycastResults[index].gameObject.name);
            var  go            = m_RaycastResults[index].gameObject;
            bool appendGraphic = true;
            if (ignoreReversedGraphics)
            {
                // If we have a camera compare the direction against the cameras forward.
                Vector3 cameraFoward = eventCamera.transform.rotation * Vector3.forward;
                Vector3 dir          = go.transform.rotation * Vector3.forward;
                appendGraphic = Vector3.Dot(cameraFoward, dir) > 0;
            }

            if (appendGraphic)
            {
                float resultDistance = 0;

                Transform trans        = go.transform;
                Vector3   transForward = trans.forward;
                // http://geomalgorithms.com/a06-_intersect-2.html
                float transDot = Vector3.Dot(transForward, trans.position - ray.origin);
                float rayDot   = Vector3.Dot(transForward, ray.direction);
                resultDistance = transDot / rayDot;
                Vector3 hitPosition = ray.origin + (ray.direction * resultDistance);
                resultDistance = resultDistance + 0;

                //Debug.Log("resultDistance : "+ resultDistance+ "      hitDistance : "+ hitDistance + "   dist "+dist);

                // Check to see if the go is behind the camera.
                if (resultDistance < 0 || resultDistance >= hitDistance || resultDistance > dist)
                {
                    continue;
                }

                //Transform pointerTransform =
                //  GvrPointerInputModule.Pointer.PointerTransform;
                //float delta = (hitPosition - pointerTransform.position).magnitude;
                //if (delta < pointerRay.distanceFromStart)
                //{
                //    continue;
                //}

                RaycastResult castResult = new RaycastResult
                {
                    gameObject     = go,
                    module         = this,
                    distance       = resultDistance,
                    worldPosition  = hitPosition,
                    screenPosition = eventCamera.WorldToScreenPoint(hitPosition),
                    index          = resultAppendList.Count,
                    depth          = m_RaycastResults[index].depth,
                    sortingLayer   = canvas.sortingLayerID,
                    sortingOrder   = canvas.sortingOrder
                };
                resultAppendList.Add(castResult);
            }
        }
        //Debug.Log("resultAppendList.Count   :  " + resultAppendList.Count);
    }