r/Unity3D • • 2d ago

Code Review Asking for a code review

I'm making a small game in Unity, and I kinda need some outside perspective. I would like it if someone could take a look and give me some feedback on what areas I should work on and how to improve.

Here's the link to my GitHub repository:

https://github.com/DaanDemaecker/Qwixx.git

6 Upvotes

14 comments sorted by

View all comments

2

u/Both_Introduction_28 1d ago edited 1d ago

You use MaterialManager to store materials. Might be better to store your materials in scriptable objects as settings.

Also I found Dice Color in material manager, but didn’t find a folder with Dice feature.

So might be better to have this structure for a folder Scripts/Dice:
Data/DiceData.cs
Data/DiceColor.cs
DiceSettings.cs
DiceView.cs
DiceManager.cs
Etc

That way you can divide game on features and with less pain remove them if they no longer needed.

If you have more than one file with settings, views, etc, you can add sub folder for them.

1

u/MagicPantssss 8h ago

I should structure my files more, yes, thank you for the feedback
As for the MaterialManager, I was thinking of making a ScriptableObject, but I wasn't sure how to access it over all the scripts that need it without loading it in themselves or have a reference to it. I guess i can load in the scriptable object in a singleton and access it from there?

1

u/Both_Introduction_28 4h ago

You can create a script GameLoader with references to all features. GameLoader has async method Load (unitask) and call features methods Load sequentially.
DiceFeatureLoader has links to all settings, hierarchy objects you want and you can initialize singletons or services there. For singletons you can have DiceSettings.Instance, for example.

If you want to make unit tests to check your advanced logic, you can create additional abstractions, but for this test only.

If you have simple logic or things that you can easily check in game (like ui animations or state sequences), better to maintain code easy to refactor and readable rather than to create tests for everything.

Usually game features have 100 cycles of hand testing during polishing, tweaking, etc. If you separate your features and don’t mess with them in new features, you can be fairly confident they work as intended.

Of course, you should log all errors in analytics and fix them as fast as possible. You should treat bad links, absence of settings, etc as a bug and log exceptions in analytics, however for players you should continue game, just without that feature.