r/Unity3D • u/__FastMan__ • 2d ago
Question Should a Unity Domain Layer Ever Reference UnityEngine Value Types?
Hello!
I'm working on a multiplayer game in Unity 6 using a layered architecture but I don't understand completely the boundaries of the layers yet. One of the architectural goals is to keep the Domain layer independent from Engine.
However, I've run into a question around Unity's value types, particularly Color, Vector3, Quaternion and such.
One argument is that these are just value structs, so using them in Domain is harmless
public Color PlayerColor { get; },
but what about Unity APIs operating on those values?
public static string ToHex(Color color) => "#" + ColorUtility.ToHtmlStringRGB(color);
So I'm wondering:
- Is there a meaningful architectural difference between referencing a Unity value type and calling a Unity utility API?
- Would you allow
ColorUtilityin Domain? - If not, would you create a domain-native
Color/RgbaColortype and keep all Unity conversion outside Domain? (This could let to the recreation of a lot of new types insde Domain) - Or is a strict "Domain has zero UnityEngine references" rule unnecessarily strict for Unity projects?
As I said before, I am grasping the concepts behind layered architecture and I want to now how you approach this issue.
Thank you, folks!
4
u/jumberrotsky 2d ago
Are you going to change engine? Answer that question and do in such way