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

Canvas Buttons work in editor but not build

Discussion in 'Editor & General Support' started by knobby67, Mar 22, 2019.

  1. knobby67

    knobby67

    Joined:
    Aug 30, 2015
    Posts:
    385
    Hi All,
    my code was working fine until yesterday. But today buttons on my canvas are not detected in build. They work fine in editor. But when I build nothing. I've added a bit of code to detect and log what objects the eventsystem sees and it sees background objects fine. I don't think it can be used to see canvas objects? Using the unity example for m_MyGameObject = hit.collider.gameObject.

    I should also add if I swap to a menu scene etc canvas buttons work on here, swap back and they still don't work on my main game screen

    Can anyone advise why buttons would work in editor but not build ( on the main scene )? Is there anyway I can get the eventsystem to report on these? Thanks.
     
    ryzeonline likes this.
  2. ryzeonline

    ryzeonline

    Joined:
    Feb 10, 2020
    Posts:
    27
    I have the same problem. Searched everywhere.

    People suggest all kinds of things.

    -Render Camera on the Canvas
    -Z-Position of the Canvas or UI Elements
    -Material/Shader of UI Elements
    -SortOrder of Canvas or UI Elements

    I don't know if it's any of these. I don't know how to debug it. I'd love a solution or method to debug that works.

    Sorry I can't be more helpful.
     
  3. LatchGameDev

    LatchGameDev

    Joined:
    Nov 24, 2014
    Posts:
    61
    I mean this probably won't help but if you suspect something at runtime might start blocking the button you can also try the Canvas Group since that has a "Block Raycast" and "Interactable" Check Boxes.

    But If i was having the issue i'd debug it by copying my scene and then just start removing more and more things until it worked again. Then try and figure out from there what breaks it when I add it back in. If you get down to a scene with a brand new canvas, new button, and event system with the issue still happening i'd submit a bug report, i mean never done a bug report but I assume unity has bug reporting somewhere on the site.

    Also if either of you want to slim your project down (Remove everything that isn't necessary to see the UI problem happening) and send it i'll take a crack at it.
     
    Last edited: Apr 7, 2020
    ryzeonline likes this.
  4. ryzeonline

    ryzeonline

    Joined:
    Feb 10, 2020
    Posts:
    27
    Thanks so much @LatchGameDev , and very kind of you to offer to sort out a pared-down version if necessary.


    For now, your advice a great pointer in the right direction and a smart way to debug it, I'll see what I can do.
     
  5. knobby67

    knobby67

    Joined:
    Aug 30, 2015
    Posts:
    385
    Can't really help as I suspect you've tried my solution.
    Mine was a bit of text box went over the button. My solution
    1. Checked all UI elements for overlap
    2. Made buttons last elements in Canvas
     
    ryzeonline likes this.
  6. ryzeonline

    ryzeonline

    Joined:
    Feb 10, 2020
    Posts:
    27
    Thanks so much, and that's a solution that will work for some people, so I'm glad you shared it here, thank you :)
     
  7. leonardo13j

    leonardo13j

    Joined:
    Mar 31, 2022
    Posts:
    3
    Hello!
    I had the same problem. I do recommend include Graphyc Raycaster (GR), but they should be placed in not overlaped areas.
    I had a master "Canvas" element, parent of thers "MainMenu", "Settings", "Others". The problem was I have GR on master canvas, settings and others menus. I deleted the GR on master canvas and add one to MainMenu, and all warked. I think the reason is now they are not overlaping.