Search Unity

Official New free e-book and demo: Create modular game architecture in Unity with ScriptableObjects

Discussion in 'Scripting' started by thomas_jacobsen_unity, Apr 20, 2023.

  1. thomas_jacobsen_unity

    thomas_jacobsen_unity

    Unity Technologies

    Joined:
    Dec 7, 2016
    Posts:
    22
    Hey everyone,

    Our new 70+ pages e-book, Create modular game architecture in Unity with ScriptableObjects, which provides best practices from professional developers for deploying ScriptableObjects in production, is now available for download.

    Along with the e-book, you can download a demo project from GitHub inspired by classic arcade game mechanics. The demo shows how ScriptableObjects can help you create components that are testable and scalable, while also being designer-friendly. Although a game like this could be built with far fewer lines of code, this demo shows ScriptableObjects in action.

    Header-600x300.png

    Here’s a preview of what you can find in the guide:
    • Introduction to ScriptableObjects
    • ScriptableObjects versus MonoBehaviours
    • Data containers
    • Design patterns: Extendable enums, Delegate objects, Observer, Command
    • Walkthrough the paddle game demo project
    >> Download the guide


    We hope you find these resources helpful in your work! As always, please share any suggestions and feedback in the comments here.
     
    Last edited: Apr 20, 2023
    Nad_B, nlhoang_VNDC, jboadas and 5 others like this.
  2. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    Scriptable objects are great, This is a nice e-book that I will definitely keep around.

    But when scriptable objects are mixed with the addressables package it can be a nightmare.
    The e-book does not mention anything about using addressables or asset bundles. Not any reference that I could find quickly.

    Once you have scene references and addressable references to scriptable objects they're not the same object anymore.
    So any shared data will be broken because it is a different instance of the scriptable object.

    So for example, if the UI is loaded through addressables and your player is a built-in prefab (not addressable). When they share the same PlayerHealth scriptable object, they will be different instances of the scriptable object.
    If the player would take damage, the UI wouldn't know about it.

    One way I used to avoid this issue is to make literally everything addressable.
    Only a bootstrap scene that is built-in to then from that point on only load addressable scenes.

    It would be nice if Unity found a solution to that problem in some way that does not involve moving everything to addressables.
    You want to be able to update or release DLC content after a build is live. But that will be difficult if you're using scriptable object references everywhere.
     
    SisusCo and Chubzdoomer like this.
  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,914
    To be fair this is just a side-effect of assets getting duplicated across asset bundles/addressables groups. Addressables has an Analyze window that will show you exactly what assets are getting duplicated across your groups.

    Naturally you should be using that regularly to ensure there are no duplicated assets.

    If you plan to use addressables or asset bundles then you're pretty much all in, yeah. It's more or less the expected workflow. Though as you can make entire folders addressable, it's not that hard to set up some primary folders that contain the majority of your assets without having to micromanage it yourself.
     
    kei233, MaskedMouse and Ryiah like this.
  4. thomas_jacobsen_unity

    thomas_jacobsen_unity

    Unity Technologies

    Joined:
    Dec 7, 2016
    Posts:
    22
  5. davidnibi

    davidnibi

    Joined:
    Dec 19, 2012
    Posts:
    426
    Thanks, will have a read through this as I've never used them before.
     
  6. jacob1818

    jacob1818

    Joined:
    Aug 20, 2013
    Posts:
    1
    upload_2024-4-11_14-48-0.png

    Great series!
    Quick question: Which script is responsible for the part that the listeners are listed? Is it a customeditor or something else?
    Thanks

    -edit-
    Oh I've found it, it's the script VoidEventChannelSOEditor.cs (EventChannels/Editor folder)
     
    Last edited: Apr 11, 2024