Exemple #1
0
    void HandleOnInputPointerUp(int inputIndex, InputPointerParameters pointerParams, InputPointer sender)
    {
        IPointerUpHandler[] enterHandlers = pointerParams.target.GetComponents <IPointerUpHandler>();

        foreach (var handler in enterHandlers)
        {
            PointerEventData data = new PointerEventData(eventSystem);
            handler.OnPointerUp(data);
        }
    }
    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);

                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);

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

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

        base.PointerInputDown(inputIndex, inputParams, input, raydepth, behindGui);
    }
Exemple #3
0
    protected override void PointerInput(int inputIndex, InputParameters inputParams, BaseInput input, int raydepth, bool behindGui)
    {
        Ray gearRay = new Ray(transform.position, transform.forward);

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

                InvokeInputPointer(inputIndex, ipp);

                if (isGUIPointer)
                {
                    behindGui = true;
                }

                raydepth++;
            }
        }
        else
        {
            RaycastHit hit;
            if (Physics.Raycast(gearRay, out hit, rayDistance, mask))
            {
                IsSelected(inputIndex, hit);

                var ipp = new InputPointerParameters(hit, raydepth, this, behindGui);
                ipp.SetInput(input, inputParams, gearRay);

                InvokeInputPointer(inputIndex, ipp);

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

        base.PointerInput(inputIndex, inputParams, input, raydepth, behindGui);
    }
Exemple #4
0
 void HandleOnInputPointer(int inputIndex, InputPointerParameters pointerParams, InputPointer sender)
 {
 }
    protected override void PointerInputUp(int inputIndex, InputParameters inputParams, BaseInput input, int raydepth, bool behindGui)
    {
        Ray inputRay = GetComponent <Camera>().ScreenPointToRay(inputParams.position);

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

                if (IsSelected(inputIndex, hit))
                {
                    ipp.inputTimedClick = timeClick;
                    InvokePointerClicked(inputIndex, ipp);
                    RemoveSelected(inputIndex, hit);
                }

                InvokeInputPointerUp(inputIndex, ipp);

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

            foreach (var remainingpp in GetSelected(inputIndex))
            {
                var ipp = new InputPointerParameters(remainingpp.target, this);
                ipp.SetInput(input, inputParams, inputRay);

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

                InvokeInputPointerUp(inputIndex, ipp);

                if (IsSelected(inputIndex, hit))
                {
                    ipp.inputTimedClick = timeClick;
                    InvokePointerClicked(inputIndex, ipp);
                    RemoveSelected(inputIndex, hit);
                }

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

            foreach (var remainingpp in GetSelected(inputIndex))
            {
                var ipp = new InputPointerParameters(remainingpp.target, this);
                ipp.SetInput(input, inputParams, inputRay);

                InvokeInputPointerUpExternal(inputIndex, ipp);
            }
        }

        ClearSelected(inputIndex);

        base.PointerInputUp(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);
    }
Exemple #7
0
 void HandleOnInputPointerUp(int inputIndex, InputPointerParameters pointerParams, InputPointer sender)
 {
     pointerParams.target.SendMessage("OnPress", false, SendMessageOptions.DontRequireReceiver);
 }