1
\$\begingroup\$

I'm developing a 3D platformer video game on Unity3D and I've been asked to present its UML class diagram and data model. If I'm not mistaken Unity uses an entity-component-system, which necessarily doesn't use heritage. How would a class diagram from a Unity game look like, in that case?

Also, I've been taught that usually data model refers to entity-relationship-models that represent a database. In the case my game doesn't use a database, how could I diagram the way the player's data is store on the game? I'm storing the player progress on a file in the user's computer.

\$\endgroup\$
  • 3
    \$\begingroup\$ "how could I diagram the way the player's data is stored in the game?" well, that depends on how you are storing the player's data. We can't help you to diagram your approach until you explain to us what that approach is. \$\endgroup\$ – DMGregory Jun 25 '18 at 1:06
1
\$\begingroup\$

It is possible to have MonoBehaviours which use inheritance, but in most Unity projects that's rather the exception than the norm. So an UML class diagram focusing on inheritance for a by-the-book Unity project would show many, many classes all inheriting from MonoBehaviour. But to improve readability, framework classes are usually omitted from class diagrams, so you would have a bunch of stand-alone classes not connected at all.

That would obviously not be very useful.

But what you could do instead is visualize dependency relations. Whenever one of your behaviors uses GetComponent<OtherMonoBehaviour>(), that behaviour has a dependency on the other behaviour. UML class diagrams have an arrow for that. When a behaviour keeps references to a group of other behaviours, then you have an aggregation. There is also an arrow for that.

You could also stretch the definition of "class" a bit and display different types of game objects as if they were classes. In that case:

  • Prefab relations could be visualized as inheritance
  • Objects which contain sub-objects can be visualized as a composition
\$\endgroup\$
0
\$\begingroup\$

Definitely check out doxygen. It's an open source tool which generates an API reference like documentation from source code. It's not the slickest tool out there but it does the job quite well and is used by many.

I use it from time to time to generate a technical but visual overview of all of the project's components. You'll get a good representation of how your code is organized and identifiy some design issues just by looking at some boxes and arrows. doxygen supports a couple of different languages like C/C++/C#/Java, so there's no issue by using Unity. It probably won't show you everything but it's a good start.

This is the (admittedly a bit dusty looking) general style of what doxygen does for you:

enter image description here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.