• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
Question by Visionary13 · Feb 10, 2016 at 10:28 AM · uiraycastcollidermouselock-cursor

Unity 5 UI not blocking Raycast Collider ( Physics Raycast )

In my project I'm using the Unity UI to make the inventory of the character. at the scene, there are objects with raycast that when they are clicked, activate a UI with information about them. if i'm in front of these same objects, and Enabled the IU Inventory, and click on the objects with Raycast, the UI with information about it appears, and hinders the process of inventory. I tried a few methods to make the UI block Raycast Collider (Physics Raycast). The only one that worked was this:

At the top: using UnityEngine.EventSystems;

In Void Update: if (EventSystem.current.IsPointerOverGameObject ()) {

In the editor of Unity, everything works perfectly. But the problem is in the build, which does not work. I use:

void Start () {

Screen.lockCursor = true;

Cursor.visible = false;

To lock the mouse pointer in the center of the screen, and i see if disable this function, the script with Collider Raycast (Physics Raycast) works perfectly in the build.

So I was wondering if someone can help me, can be a method to make the UI block Raycast Collider (Physics Raycast), or some other method to lock and hide the mouse pointer, or something similar.

in short: I need a method, to make the UI block Physics Raycast (Raycast Collider).

Note: sorry for bad English, I used a translator.

Comment

People who like this

0 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image

Answer by Clonus · Feb 11, 2016 at 06:41 PM

I am experiencing the same issue. I have been using this to hepl me understand what is going on. So far no luck with various blogs or posts.

 void OnMouseDown()
     {
 Debug.Log("MouseDown");
         Debug.Log(string.Format("IsPointerOverGameObject() : {0}",EventSystem.current.IsPointerOverGameObject()));
     }
 
     void OnMouseUp()
     {
         Debug.Log("MouseUp");
         Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit;       
         Physics.Raycast(ray, out hit);
         Debug.Log(string.Format("HitPoint : {0}", hit.point));
 
     }

Comment

People who like this

0 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Visionary13 · Feb 20, 2016 at 11:19 PM 0
Share

thnx man :)

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

onmouse over UI pop up help please 0 Answers

NullReference in Eventsystem Raycast eventCamera 0 Answers

AR Foundation ARRaycastmanager ray passing through UI,AR Foundation - ARRaycastmanager ray passing through UI 1 Answer

SteamVR Laser OnPointerClick not work with UI Element 0 Answers

UnityEngine.Screen does not contain a definition for 'fullscreen' 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges