예제 #1
0
    public static bool CursorRayhit(Collider coll, out RaycastHit rh)
    {
        Ray       ray      = Camera.main.ScreenPointToRay(Input.mousePosition);
        LayerMask collMask = LayerMask.GetMask(LayerMask.LayerToName(coll.gameObject.layer));
        int       i        = 0;

        do
        {
            if (Physics.Raycast(ray, out rh, 100f, collMask))
            {
                if (rh.collider == coll)
                {
                    return(true);
                }
                else
                {
                    ray = RaycastMaster.RaySlightlyBelowHit(ray, rh);
                }
            }
            else
            {
                break;
            }
        } while (++i < 5);
        return(false);
    }
예제 #2
0
    public static HashSet <Collider> CollidersPiercedBy <T>(Ray ray, int depth, LayerMask layerMask, bool wantCursorInteraction) where T : MonoBehaviour
    {
        RaycastHit         rayHit;
        HashSet <Collider> ciColliders = new HashSet <Collider>();

        for (int i = 0; i < 5; ++i)
        {
            if (Physics.Raycast(ray, out rayHit, 100f, layerMask))
            {
                //TODO: iron-out awkward logic here. Could use a dynamic type? instead of the 'want' bool?
                if (wantCursorInteraction && rayHit.collider.GetComponentInParent <T>() == null)
                {
                    break;
                }
                else
                {
                    ray = RaycastMaster.RaySlightlyBelowHit(ray, rayHit);
                    ciColliders.Add(rayHit.collider);
                }
            }
            else
            {
                break;
            }
        }
        return(ciColliders);
    }
예제 #3
0
 // Start is called before the first frame update
 void Start()
 {
     Launcher = LaunchersObject.GetComponent <BallLauncherController>();
     Ray      = RayCast.GetComponent <RaycastMaster>();
     text     = TextObj.GetComponent <Text>();
     TotText  = TotTextObj.GetComponent <Text>();
 }
예제 #4
0
파일: DragDrop.cs 프로젝트: melsov/MyLandz
    protected override void OnMouseDrag()
    {
        if (disabled)
        {
            return;
        }
        transform.position = cursorOnTransform + dragRelative;
        DropBox nextBox = RaycastMaster.ComponentUnderCursor <DropBox>(collidr);

        if (nextBox)
        {
            dropBox = nextBox;
            dropBox.canAccept(transform);
        }
        else
        {
            if (dropBox)
            {
                dropBox.cancel();
                dropBox = null;
            }
        }
    }