2

I'm currently at the verge of a mental breakdown. I spent hours building my own laser pointer, making it shoot raycasts on everything and try to make it work with my UI. But it won't. At least not correctly.

What works: Raycast and draw line.

Where I struggle: Right now I have two options. A) Standard UI button and cube without mesh renderer to it. This makes the button fade thru its animations according to its button script. BUT it won't resolve the On button click events! So I added an event trigger onto the button - which... will indeed trigger the "pointer enter" events! But not its "pointer click" events :(

So what I thought: my click must be implemented wrong! To test this: B) Added an event trigger to the cube, that's the buttons collider. Set it to "pointer click". And tada! it works! BUUUUT this kills the animation of the button! Why?

Thankful for any ideas! I'd also take new startpoints into consideration, if you have a good hint!

Next issue are sliders. Any tipps on how to make them work?

Thanks for any help!!

Cheers Flo

Edit: current code:

        {//Record this data and tell the object that we are pointing at them (OnPointerEnter)
        eventData.pointerEnter = rayHit.transform.gameObject;
        ExecuteEvents.ExecuteHierarchy(eventData.pointerEnter, eventData, ExecuteEvents.pointerEnterHandler);


        //If trigger becomes state down ...
        if (SteamVR_Actions._default.GrabPinch.GetStateDown(handType) && eventData.pointerEnter != null)
        {
            //...tell the object that we have pressed it (OnPointerDown)
            eventData.pointerPressRaycast = eventData.pointerCurrentRaycast;
            eventData.pointerPress = ExecuteEvents.ExecuteHierarchy(eventData.pointerEnter, eventData, ExecuteEvents.pointerDownHandler);
        }
        //Otherwise, if we just released the primary input axis...
        else if (SteamVR_Actions._default.GrabPinch.GetStateUp(handType))
        {
            //...tell the object than we have stopped pressing it (OnPointerUp)
            if (eventData.pointerPress != null)
                ExecuteEvents.ExecuteHierarchy(eventData.pointerPress, eventData, ExecuteEvents.pointerUpHandler);

            //...finally, if we pressed and released the same object, then we have clicked it (OnPointerClick)
            if (eventData.pointerPress == eventData.pointerEnter)
                ExecuteEvents.ExecuteHierarchy(eventData.pointerEnter, eventData, ExecuteEvents.pointerClickHandler);

            eventData.pointerPress = null;
        }
    }
2
  • Thanks for adding the code, it's still kind of hard to figure out what's happening. What part of the code doesn't do what you want? Commented Feb 27, 2019 at 8:25
  • @ILiveForVR I commented your answer - does that clarify the issue / my confusion? Commented Feb 27, 2019 at 8:27

1 Answer 1

1

Without code it's hard to tell, but I think you are overriding the pointer click events with your own? That would explain why the animations are gone. You could resolve it by calling the event on the base class. base.OnPointerClick() or something like that.

Sign up to request clarification or add additional context in comments.

8 Comments

I added my code above. My bad! I don't understand tho how the buttons event trigger can fire on pointerEnter, but doesn't react to pointerClick. Whereas the cube clearly understands pointerClick events but takes out the animation (I guess the buttons interactability is gone then)
Just added an event to every case. The button's event trigger component reacts to everything but the pointerClick. Which is unreasonable to me! Because the cube's event trigger clearly differentiates between PointerUp and pointerClick
Where are you setting pointerPress in the second part of you code? You're checking for it, but I can't see where it's set. This is one thing that's different from your first piece of code, where you are setting pointerEnter
pointerPress doesn't have a pointerPressHandler within the ExecuteEvents-system. Therefor I use the pointerClickHandler instead. (if we pressed and released the same object, then we have clicked it (OnPointerClick))
Ah, so the second piece of code is for the object? And the first is your pointer? Because you set eventData.pointerEnter = rayHit.transform.gameObject; but I can't see where you set 'eventData.pointerPress' for the 'else if' part of your code. You set it in the first if, but that will never reach the else if right?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.