r/unity • • 13h ago

Coding Help Seemingly logical code doesnt seem to work

Post image
8 Upvotes

This code is meant to receive 2 fonts, and all the text on the current scene, and then apply the font that isnt active to the text. I have properly assigned the font assets, but when clicking a button what happens is, the font changes to "dyslexiafont" then gives me the debug from the else statement (which is not the dyslexia font) and when clicking the button again nothing happens.

Ive ran this through multiple AI's and they all seem to just slightly edit my code by adding some validation, but that doesnt do anything and any time i explain the issue they just claim ive assinged the fonts wrong, but i have checked multiple times if the font asset is in the right place and it is.

I assume that either i cant apply font like this (but it does apply just once and completely messy)

Or im missing something. Any help is appreciated else ill just pretend it works.


r/unity • • 14h ago

Showcase Unity game INFINITE CHUMP finds a publisher!

9 Upvotes

Happy to add this game to my incredible roster! Go check out the demo on steam


r/unity • • 17h ago

Showcase How to max out the satisfaction from bubble popping in my game? Maybe more impact VFX? Or caustics on the bubbles?

3 Upvotes

r/unity • • 18h ago

Showcase How I sort raycast hits so a click picks the log inside a machine, not the machine itself

4 Upvotes

In my sawmill sim every log is a rigidbody, and most of the time it sits inside something:

a machine, a conveyor, a pile of other logs. My first version used a single Physics.Raycast, so players kept selecting the machine housing or a trigger zone instead of the log they actually clicked on.

What I do now:
- Physics.RaycastNonAlloc with a reused 128-hit buffer (no GC per frame.. enough for big piles)
- sort the hits by distance myself, because RaycastNonAlloc doesn't return them sorted
- walk the hits and take the first collider tagged as a log that has a LogController
-machine colliders and trigger zones don't stop the search, the ray just keeps going through them
- terrain and ground do stop it, so you can't pick a log through the floor
- logs that are already packed in a box, and veneer logs, are skipped
- hover and click use the same resolver, so what lights up is exactly what you click

Simplified, it looks like this:

int count = Physics.RaycastNonAlloc(ray, hits, maxDistance);
System.Array.Sort(hits, 0, count, byDistance);
for (int i = 0; i < count; i++)
{
var col = hits[i].collider;
if (IsGround(col)) break;
if (!col.CompareTag("Stamm")) continue;
var log = col.GetComponentInParent<LogController>();
if (log != null && log.IsPickable) return log;
}
return null;

The biggest lesson.... one resolver for hover and click. Before that, the highlight sometimes showed one log and the click picked another, and that felt like a bug even when it technically wasn't.

The clip shows hover and click on a log in the middle of a running machine.

How do you handle click priority when lots of colliders overlap? Layers only, or something like this..?

(Game, if you're curious: https://store.steampowered.com/app/5037170/Timberline_Factory/)


r/unity • • 23h ago

Showcase I made a simple UI outliner.

Thumbnail redstoneinvente.itch.io
2 Upvotes

YouTube showcase

Hello there, i recently made a small, basic UI outliner for unity. I made it because i needed something like this for my own game. If you ever need something like this, feel free to check the link out, its free.

https://redstoneinvente.itch.io/ui-outline


r/unity • • 11h ago

Game zonk racing: retro gameplay at night, with improved AI

3 Upvotes

r/unity • • 23h ago

Showcase Any feedback on my Fishing simulator Sunset?

Post image
12 Upvotes

I'm the solo dev of Maré. I've been developing it without AI for almost 2 years. This is the second section of the game, and it includes this sunset.

Wishlist Maré on Steam pls: https://store.steampowered.com/app/3918760/Mar%C3%A9/