Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

OnMouseUp() not working on pc build

Discussion in 'Scripting' started by Myrmidou, Nov 29, 2016.

Thread Status:
Not open for further replies.
  1. Myrmidou

    Myrmidou

    Joined:
    Jun 7, 2014
    Posts:
    30
    Hi there!

    On my current project I use OnMouseUp() as a raycast to get a go, like this:
    Code (CSharp):
    1.  
    2.         public virtual void OnMouseUp() {
    3.  
    4.             if (Utils.IsPointerOverUIObject()) {
    5.                 return;
    6.             }
    7.          
    8.             else {
    9.                 this.ActivateRelatedUI();
    10.             }
    11.         }
    It's working at runtime but not after a build on pc. I made some tests and it seems that a click's "raycast" has a limited lenght, as I need to be close enough to a go to be able to click on it. Is it possible to make it infinite like a typical raycast? Is it better to use only raycasts?

    Thanks :)
     
  2. Myrmidou

    Myrmidou

    Joined:
    Jun 7, 2014
    Posts:
    30
    Edit: I changed my script to a simple raycast and I don't have the range issue anymore. It still doesn't work on build though.
     
  3. takatok

    takatok

    Joined:
    Aug 18, 2016
    Posts:
    1,496
    I know OnMouseDown is only called when you press the Mouse Down over a GUI Element or a collider. I believe OnMouseUp is then called wherever you release the mouse button. However, if you don't trigger the initial OnMouseDown ( you pressed the mouse when it wasn't on a GUI Element or a collider) , then I don't believe OnMouseUp is called.

    You can use IPointerDown and IPointerUp interfaces to get OnPoInterUp callbacks. Or you can check Input.GetMouseButtonUp in Update function to get the frame that the mouse is clicked up.
     
  4. gibfredg13

    gibfredg13

    Joined:
    May 18, 2022
    Posts:
    1
    hi i tried onmouseup and it doesn't do any thing i don't know if its a rendering issue or some thing so the i tried on mouse resale but it doesn't do anything either it just keeps the bird the same colour
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,557
    Please don't necro old posts for what you assume to be the same problem. Please just create your own thread with your own details. You don't provide any detail here for anyone to help you.
     
Thread Status:
Not open for further replies.