Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
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
Add comment
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

· Add your reply
  • Sort: 
avatar image
0

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
Add comment · 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 :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

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

Laser Raycast collision point - invert collider 0 Answers

UI Button priority over box collider 0 Answers

Auto-generate optimal direction for Raycast with specifications 1 Answer

Need help with 2d shooting with raycast 0 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