How to block raycasts with Unity UI elements

While testing a new feature in an unannounced game I’m working on, I noticed some confusing behaviour in Unity: if a Screen Space UI element (such as a button) was hovering over a 3D model in the game, clicking on the UI button would work as expected, but the model under the button was also reacting as though it had been clicked on. This was obviously not the behaviour I wanted.

I went searching for a solution to this problem, and I couldn’t find a simple explanation of how to solve it anywhere, so once I figured out how to solve the problem I figured I should write out what I’ve learned so that anyone else encountering the same problem could save some time. This code was tested in Unity 2021.3, but should work in other versions.

Road Map To Release

Last week saw the release of the first footage of Championship Wrestling Promoter in action with the debut trailer. If you haven’t watched it yet please check it out! CWP has been in development since early in 2020, and I’ve shown off bits of the game here and there while working on it, but they’ve all had placeholder art, incomplete designs, etc. The game is at a point where a lot of the design is locked in, and even more importantly, the art for the game is essentially finished. What CWP looks like now is what it will look like when the game is released. There’s lots of work left to do, but CWP finally looks and plays like the vision I had in my head when I first started working on the game, which made this a good time to start showing it off.

Having reached this point, the question I’ve been getting the most is, “When can I play it?” In this post I’m going to give a tentative timeline that I’m currently aiming for. This could change at any point, but the game is far enough along now that giving rough estimates is possible.

CWP Development Update, February 2022

With most of the planned major features currently in the game, focus has shifted to the last couple of big things left to do. The biggest of these is artificial intelligence. I’ve deliberately avoided putting much AI in the game prior to now, knowing that the game was likely going to undergo many changes along the way, and not wanting to create extra work by having to constantly throw out and re-write AI code. However, with a substantial amount of the code base and most of the design now done, I feel comfortable adding AI rivals to flesh out the game world.

CWP Development Update, December 2021

Last month was a pretty big one for CWP, with a lot of new things added to the game. We’re getting much closer to having an “alpha” build of the game ready, which to me means that every feature planned for the game is functional, but the game needs work on the balance, content, and of course a lot of bug squashing. So let’s dive into what’s new over the past month, and then a brief look at what’s coming next.

CWP Development Update, November 2021

The last month of development has primarily been devoted to one part of the game, and that’s tag team matches. Up until now it’s only been possible to book singles matches, so adding more match types has been one of the biggest remaining tasks in the development of Championship Wrestling Promoter. After the jump I’ll dive in to how tag matches work, and how they differ from singles matches.

CWP Development Update, September 2021

September saw the introduction of two big new features. The first is scouting. It’s now possible to build a team of scouts who will scour the globe for the next big thing, or maybe to find some great independent workers to flesh out your roster. The second new feature is the long-awaited introduction of the Trait system, which I’m pretty excited about. Scouting is pretty straight-forward, so I’ll start with a quick rundown of what that entails and then jump into Traits.

CWP Development Update, August 2021

Development work continues on the financial side of the game. Last month I talked about ticket and merchandise revenue, and those systems have been further fleshed out this month. It’s also now possible to purchase various types of marketing, which will boost revenue of one particular type or another (ignore the empty blank space, it will be filled in with some graphics eventually).