Exemple #1
0
    private void RaycastFirst(ref int raydepth, ref bool behindGui)
    {
        Ray        pointerRay = new Ray(transform.position, transform.forward);
        RaycastHit hit;

        if (Physics.Raycast(pointerRay, out hit, rayDistance, mask.value))
        {
            // Something hit, handle Enter and Over events
            PointerParameters pp;

            if (!IsActive(hit, out pp))
            {
                if (HasActives())
                {
                    InvokePointerExit(0, new BasePointerParameters(activeTarget[0][0].target, this));
                    if (clickLock.Contains(activeTarget[0][0].target))
                    {
                        clickLock.Remove(activeTarget[0][0].target);
                    }
                    ClearActives();
                }

                pp = new PointerParameters(hit, raydepth, this, behindGui);
                AddActive(pp);
                InvokePointerEnter(0, new BasePointerParameters(hit, raydepth, this, behindGui));
            }
            else
            {
                var npp = new BasePointerParameters(hit, raydepth, this, behindGui);

                InvokePointerOver(0, npp);

                if ((npp.time - pp.time) > clickTimeSpan && !clickLock.Contains(npp.target))
                {
                    clickLock.Add(npp.target);
                    InvokePointerClicked(0, npp);
                }
            }

            raydepth++;
            if (isGUIPointer)
            {
                behindGui = true;
            }
        }
        else
        {
            // Nothing hit, report Exit event if active objects
            if (HasActives())
            {
                InvokePointerExit(0, new BasePointerParameters(activeTarget[0][0].target, this));
                if (clickLock.Contains(activeTarget[0][0].target))
                {
                    clickLock.Remove(activeTarget[0][0].target);
                }
                ClearActives();
            }
        }
    }
Exemple #2
0
    private void RaycastAll(ref int raydepth, ref bool behindGui)
    {
        Ray pointerRay = new Ray(transform.position, transform.forward);

        RaycastHit[]      raycastHits = Physics.RaycastAll(pointerRay, rayDistance, mask.value);
        List <RaycastHit> tempActives = new List <RaycastHit>();

        foreach (var hit in raycastHits)
        {
            PointerParameters pp;

            if (!IsActive(hit, out pp))
            {
                pp = new PointerParameters(hit, raydepth, this, behindGui);
                AddActive(pp);

                InvokePointerEnter(0, new BasePointerParameters(hit, raydepth, this, behindGui));
            }
            else
            {
                var npp = new BasePointerParameters(hit, raydepth, this, behindGui);

                InvokePointerOver(0, npp);

                if ((npp.time - pp.time) > clickTimeSpan && !clickLock.Contains(npp.target))
                {
                    clickLock.Add(npp.target);
                    InvokePointerClicked(0, npp);
                }
            }
            tempActives.Add(hit);

            //Raise raycounter
            raydepth++;
        }

        //If we hit something and we are a GUIpointer then set behindGui true
        if (tempActives.Count > 0 && isGUIPointer)
        {
            behindGui = true;
        }

        List <PointerParameters> leftTargets = RemoveActivesExcept(tempActives);

        foreach (var tpp in leftTargets)
        {
            InvokePointerExit(0, new BasePointerParameters(tpp.target, this));
            if (clickLock.Contains(tpp.target))
            {
                clickLock.Remove(tpp.target);
            }
        }
    }
Exemple #3
0
    private void RaycastFirst(ref int raydepth, ref bool behindGui)
    {
        Ray gearRay = new Ray(transform.position, transform.forward);

        InvokeInputRayUpdate(0, gearRay);

        Debug.DrawRay(gearRay.origin, gearRay.direction * 50, Color.red);

        RaycastHit hit;

        if (Physics.Raycast(gearRay, out hit, rayDistance, mask.value))
        {
            // Something hit, handle Enter and Over events
            PointerParameters pp;

            if (!IsActive(hit, out pp))
            {
                if (HasActives())
                {
                    InvokePointerExit(0, new BasePointerParameters(activeTarget[0][0].target, this));
                    ClearActives();
                }

                pp = new PointerParameters(hit, raydepth, this, behindGui);
                AddActive(pp);
                InvokePointerEnter(0, new BasePointerParameters(hit, raydepth, this, behindGui));
            }
            else
            {
                var npp = new BasePointerParameters(hit, raydepth, this, behindGui);

                InvokePointerOver(0, npp);
            }

            raydepth++;
            if (isGUIPointer)
            {
                behindGui = true;
            }
        }
        else
        {
            // Nothing hit, report Exit event if active objects
            if (HasActives())
            {
                InvokePointerExit(0, new BasePointerParameters(activeTarget[0][0].target, this));
                ClearActives();
            }
        }
    }
    private void RaycastFirst(ref int raydepth, ref bool behindGui)
    {
        Ray pointerRay = GetComponent <Camera>().ScreenPointToRay(MouseInput.position);

        InvokeInputRayUpdate(0, pointerRay);

        RaycastHit hit;

        if (Physics.Raycast(pointerRay, out hit, rayDistance, mask.value))
        {
            // Something hit, handle Enter and Over events
            PointerParameters pp;

            if (!IsActive(hit, out pp))
            {
                if (HasActives())
                {
                    InvokePointerExit(0, new BasePointerParameters(activeTarget[0][0].target, this));
                    ClearActives();
                }

                pp = new PointerParameters(hit, raydepth, this, behindGui);
                AddActive(pp);
                InvokePointerEnter(0, new BasePointerParameters(hit, raydepth, this, behindGui));
            }
            else
            {
                var npp = new BasePointerParameters(hit, raydepth, this, behindGui);

                InvokePointerOver(0, npp);
            }

            raydepth++;
            if (isGUIPointer)
            {
                behindGui = true;
            }
        }
        else
        {
            // Nothing hit, report Exit event if active objects
            if (HasActives())
            {
                InvokePointerExit(0, new BasePointerParameters(activeTarget[0][0].target, this));
                ClearActives();
            }
        }
    }
Exemple #5
0
    private void RaycastAll(ref int raydepth, ref bool behindGui)
    {
        Ray gearRay = new Ray(transform.position, transform.forward);

        InvokeInputRayUpdate(0, gearRay);

        Debug.DrawRay(gearRay.origin, gearRay.direction * 50, Color.red);

        RaycastHit[]      raycastHits = Physics.RaycastAll(gearRay, rayDistance, mask.value);
        List <RaycastHit> tempActives = new List <RaycastHit>();

        foreach (var hit in raycastHits)
        {
            PointerParameters pp;

            if (!IsActive(hit, out pp))
            {
                pp = new PointerParameters(hit, raydepth, this, behindGui);
                AddActive(pp);

                InvokePointerEnter(0, new BasePointerParameters(hit, raydepth, this, behindGui));
            }
            else
            {
                var npp = new BasePointerParameters(hit, raydepth, this, behindGui);

                InvokePointerOver(0, npp);
            }
            tempActives.Add(hit);

            //Raise raycounter
            raydepth++;
        }

        //If we hit something and we are a GUIpointer then set behindGui true
        if (tempActives.Count > 0 && isGUIPointer)
        {
            behindGui = true;
        }

        List <PointerParameters> leftTargets = RemoveActivesExcept(tempActives);

        foreach (var tpp in leftTargets)
        {
            InvokePointerExit(0, new BasePointerParameters(tpp.target, this));
        }
    }
    private void RaycastAll(ref int raydepth, ref bool behindGui)
    {
        Ray pointerRay = GetComponent <Camera>().ScreenPointToRay(MouseInput.position);

        InvokeInputRayUpdate(0, pointerRay);

        RaycastHit[]      raycastHits = Physics.RaycastAll(pointerRay, rayDistance, mask.value);
        List <RaycastHit> tempActives = new List <RaycastHit>();

        foreach (var hit in raycastHits)
        {
            PointerParameters pp;

            if (!IsActive(hit, out pp))
            {
                pp = new PointerParameters(hit, raydepth, this, behindGui);
                AddActive(pp);

                InvokePointerEnter(0, new BasePointerParameters(hit, raydepth, this, behindGui));
            }
            else
            {
                var npp = new BasePointerParameters(hit, raydepth, this, behindGui);

                InvokePointerOver(0, npp);
            }
            tempActives.Add(hit);

            //Raise raycounter
            raydepth++;
        }

        //If we hit something and we are a GUIpointer then set behindGui true
        if (tempActives.Count > 0 && isGUIPointer)
        {
            behindGui = true;
        }

        List <PointerParameters> leftTargets = RemoveActivesExcept(tempActives);

        foreach (var tpp in leftTargets)
        {
            InvokePointerExit(0, new BasePointerParameters(tpp.target, this));
        }
    }
    protected override void PointerInputDown(int inputIndex, InputParameters inputParams, BaseInput input, int raydepth, bool behindGui)
    {
        //Handle Raycast for Input
        Ray inputRay = GetComponent <Camera>().ScreenPointToRay(inputParams.position);

        if (raycastAll)
        {
            RaycastHit[] raycastHits = Physics.RaycastAll(inputRay, rayDistance, mask);
            foreach (var hit in raycastHits)
            {
                InputPointerParameters ipp = new InputPointerParameters(hit, raydepth, this, behindGui);
                ipp.SetInput(input, inputParams, inputRay);

                PointerParameters pp;
                if (!IsActive(inputIndex, hit, out pp))
                {
                    pp = new PointerParameters(hit, raydepth, this, behindGui);
                    AddActive(inputIndex, pp);

                    InvokePointerEnter(inputIndex, ipp);
                }
                else
                {
                    InvokePointerOver(inputIndex, ipp);
                }

                AddSelected(inputIndex, ipp);
                InvokeInputPointerDown(inputIndex, ipp);

                if (isGUIPointer)
                {
                    behindGui = true;
                }

                raydepth++;
            }
        }
        else
        {
            RaycastHit hit;
            if (Physics.Raycast(inputRay, out hit, rayDistance, mask))
            {
                InputPointerParameters ipp = new InputPointerParameters(hit, raydepth, this, behindGui);
                ipp.SetInput(input, inputParams, inputRay);

                PointerParameters pp;
                if (!IsActive(inputIndex, hit, out pp))
                {
                    pp = new PointerParameters(hit, raydepth, this, behindGui);
                    AddActive(inputIndex, pp);
                    InvokePointerEnter(inputIndex, ipp);
                }
                else
                {
                    InvokePointerOver(inputIndex, ipp);
                }

                AddSelected(inputIndex, ipp);
                InvokeInputPointerDown(inputIndex, ipp);

                if (isGUIPointer)
                {
                    behindGui = true;
                }
                raydepth++;
            }
        }
        timeClick = false;

        base.PointerInputDown(inputIndex, inputParams, input, raydepth, behindGui);
    }
    protected override void PointerInput(int inputIndex, InputParameters inputParams, BaseInput input, int raydepth, bool behindGui)
    {
        Ray inputRay = GetComponent <Camera>().ScreenPointToRay(inputParams.position);

        InvokeInputRayUpdate(inputIndex, inputRay);

        if (raycastAll)
        {
            RaycastHit[]      raycastHits = Physics.RaycastAll(inputRay, rayDistance, mask.value);
            List <RaycastHit> tempActives = new List <RaycastHit>();
            foreach (var hit in raycastHits)
            {
                var ipp = new InputPointerParameters(hit, raydepth, this, behindGui);
                ipp.SetInput(input, inputParams, inputRay);

                PointerParameters pp;
                if (!IsActive(inputIndex, hit, out pp))
                {
                    pp = new PointerParameters(hit, raydepth, this, behindGui);
                    AddActive(inputIndex, pp);

                    InvokePointerEnter(inputIndex, ipp);
                }
                else
                {
                    InvokePointerOver(inputIndex, ipp);
                }
                tempActives.Add(hit);

                InvokeInputPointer(inputIndex, ipp);

                if (isGUIPointer)
                {
                    behindGui = true;
                }

                //Raise raycounter
                raydepth++;
            }

            List <PointerParameters> leftTargets = RemoveActivesExcept(inputIndex, tempActives);

            foreach (var tpp in leftTargets)
            {
                InvokePointerExit(inputIndex, new BasePointerParameters(tpp.target, this));
            }
        }
        else
        {
            RaycastHit        hit;
            List <RaycastHit> tempActives = new List <RaycastHit>();

            if (Physics.Raycast(inputRay, out hit, rayDistance, mask))
            {
                var ipp = new InputPointerParameters(hit, raydepth, this, behindGui);
                ipp.SetInput(input, inputParams, inputRay);

                PointerParameters pp;
                if (!IsActive(inputIndex, hit, out pp))
                {
                    pp = new PointerParameters(hit, raydepth, this, behindGui);
                    AddActive(inputIndex, pp);
                    InvokePointerEnter(inputIndex, ipp);
                }
                else
                {
                    InvokePointerOver(inputIndex, ipp);
                }
                tempActives.Add(hit);

                InvokeInputPointer(inputIndex, ipp);

                if (isGUIPointer)
                {
                    behindGui = true;
                }

                //Raise raycounter
                raydepth++;
            }

            List <PointerParameters> leftTargets = RemoveActivesExcept(inputIndex, tempActives);
            foreach (var tpp in leftTargets)
            {
                InvokePointerExit(inputIndex, new BasePointerParameters(tpp.target, this));
            }
        }
        timeClick = false;

        base.PointerInput(inputIndex, inputParams, input, raydepth, behindGui);
    }