예제 #1
0
        public static void Visualize()
        {
            if (mainCamera.IsNotNull())
            {
                CachedRay    = mainCamera.ScreenPointToRay(Input.mousePosition);
                CachedDidHit = NDRaycast.Raycast(CachedRay, out CachedHit);

                MousedAgent = GetScreenAgent(Input.mousePosition, (agent) => { return(true); });
            }
        }
예제 #2
0
        public static Vector3 GetWorldPos3(Vector2 screenPos)
        {
            Ray        ray = mainCamera.ScreenPointToRay(screenPos);
            RaycastHit hit;

            if (NDRaycast.Raycast(ray, out hit))
            {
                //return new Vector2(hit.point.x * LockstepManager.InverseWorldScale, hit.point.z * LockstepManager.InverseWorldScale);
                return(hit.point);
            }
            Vector3 hitPoint = ray.origin - ray.direction * (ray.origin.y / ray.direction.y);

            //return new Vector2(hitPoint.x * LockstepManager.InverseWorldScale, hitPoint.z * LockstepManager.InverseWorldScale);
            return(hitPoint);
        }
        public static Vector3 GetWorldPos3(Vector2 screenPos)
        {
            if (UserInputHelper.GUIManager.MainCam == null)
            {
                return(default(Vector2));
            }
            Ray        ray = UserInputHelper.GUIManager.MainCam.ScreenPointToRay(screenPos);
            RaycastHit hit;

            if (NDRaycast.Raycast(ray, out hit))
            {
                //return new Vector2(hit.point.x * LockstepManager.InverseWorldScale, hit.point.z * LockstepManager.InverseWorldScale);
                return(hit.point);
            }
            Vector3 hitPoint = ray.origin - ray.direction * (ray.origin.y / ray.direction.y);

            //return new Vector2(hitPoint.x * LockstepManager.InverseWorldScale, hitPoint.z * LockstepManager.InverseWorldScale);
            return(hitPoint);
        }
예제 #4
0
        //public static GameObject FindHitObject(Vector3 origin)
        //{
        //    if (mainCamera == null) return null;
        //    Ray ray = mainCamera.ScreenPointToRay(origin);
        //    RaycastHit hit;
        //    if (NDRaycast.Raycast(ray, out hit))
        //    {
        //        return hit.collider.gameObject;
        //    }
        //    return null;
        //}

        public static bool HitPointIsGround(Vector3 origin)
        {
            if (mainCamera == null)
            {
                return(false);
            }
            Ray        ray = mainCamera.ScreenPointToRay(origin);
            RaycastHit hit;

            if (NDRaycast.Raycast(ray, out hit))
            {
                GameObject obj = hit.collider.gameObject;
                if (obj)
                {
                    return(obj.transform.parent.name == "Ground");
                }
            }
            return(false);
        }
        public static bool HitPointIsGround(Vector3 origin)
        {
            if (UserInputHelper.GUIManager.MainCam == null)
            {
                return(false);
            }
            Ray        ray = UserInputHelper.GUIManager.MainCam.ScreenPointToRay(origin);
            RaycastHit hit;

            if (NDRaycast.Raycast(ray, out hit))
            {
                GameObject obj = hit.collider.gameObject;
                //  did we hit the defined ground layer?
                if (obj &&
                    obj.layer == LayerMask.NameToLayer("Ground"))
                {
                    return(true);
                }
            }
            return(false);
        }