Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Q: EventSystems: what do buttons have that objects dont? A: Camera needs a physics Raycaster

Discussion in 'Scripting' started by Ne0mega, Feb 25, 2021.

  1. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    745
    I have been trying to get eventsystems interfaces like IPointerEnter to work on game objects for days now. I finally decided to pop my scripts using these interfaces on UI buttons, and they work.

    What do I need to do to make a game object (3d with collider) behave like a button when it comes to using the event systems?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,893
    You need a Collider on the object and an EventSystem in the scene. You might also need a PhysicsRaycaster on your camera, but I'm not 100% sure about that part.
     
    Ne0mega likes this.
  3. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    745
    I had Colliders and EventSystems 100 different ways from sunday, and different layers, no worky.

    I put a physics raycaster on my camera... now worky. That was it.

    TY
     
    PraetorBlue likes this.
  4. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    745
    Now it is blocking my scripted physics.raycasts. That's Event Mask is for. Got it.