Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Design pattern templates

Discussion in 'Scripting' started by Zymes, May 22, 2019.

  1. Zymes

    Zymes

    Joined:
    Feb 8, 2017
    Posts:
    118
    Are there no design pattern templates you can use to insert into your projects? I am talking about events, pub/sub, interactions between objects, MVC, MVVM etc. Common stuff that is reusable in almost all projects.

    It seems I need to write everything from scratch by reading theory.

    A lot of best practices and common tasks are the same in a lot of games.

    But I can't really find any boilerplate to solve a lot of common issues. It would be great if there were more common boilerplates, templates, opinionated architectures already made. Like modular frameworks.

    There are some assets on the store but those are monolithic frameworks.

    I come from a webdev background and I can pull in a lot of community packages and work on my app, a bit like buildings blocks instead of building the engine itself.

    I wish Unity was more like this, or the open source community around Unity rather.
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Websites don't have nearly the variation in design that games do. At this point websites are pretty standardized, so lend themselves well to construction using a "building blocks" approach. Sorry I'm not actually helping with your issue.
     
    lordofduct likes this.
  3. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    I believe you should be looking at this slightly different. Coming from webdev, Unity may look mostly unregulated, with few standards. But if you look more closely, you'll find that web development is a more focused, much more narrow case of development that allows for focused development, much like developing for mobile devices is much more focused than for Desktops (mind you, nobody ever said it's simpler, just more focused).

    Unity has already standardised a lot - so much in fact, that some people are lamenting its rigidity. Unity employs strong design patterns (implicit MVC, observer pattern, singletons, OOP, opportunistic GC, authority model for Networking, Rendering pieline, shaders) that are aligned with it's backbone of order of execution - probably the most important aspect of unity hidden out of sight for reasons unfathomable. But it is an order of magnitude less rigid than web development for the simple reason that the scope of applications possible is much wider. The same Unity is used to create a 2D 'whack-a-mole' cartoonish click game and a fully immersive multiplayer VR space combat exploration game.

    Also, just like in web development, there is a large body of templates you can use for your work in Unity - much of it avalable from the asset store.

    The cause for that is simple: the challenge in game development is usually radically different from web development. In web development, due to the infratructure and enforced compatibiliy, interface and MVC are quite rigid. The challenge lies mostly in designing intuitive, performing and above all clear structures that allow the user to quickly achieve what they want, and present the results in a pleasing, accessible way.

    Games, on the other hand, strive to captivate and immerse the Player. For this, not even the UI is standartized. There are concepts known to work, but seemingly simple things like fitting an UI to a game is a make or break decision and usually is much more than downloading a boilerplate pack. That's not to belittle web dev - it's just that the spectrum of decision in game dev is much wider. For example, the simple act of pressing a button can be cause for headache: how do you press a button in a game where the user is wearing a VR Headset and not using a mouse? Do they have a Controller to Point? Use gaze-acticvation? How do you present the feedback? There's no readily available, accepted solution - but there are some packs available on the asset store that may get you half way.

    So, for the most part, using a pattern is as much your active, conscious choice in game dev as is defining the style for your web design in web dev. And as much as choosing a pattern is an important part of game dev, half of the time you are left to blaze your own trail.
     
    Last edited: May 23, 2019
    Joe-Censored likes this.