Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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


    Unity Technologies

    Dec 7, 2016
    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.


    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
  2. MaskedMouse


    Jul 8, 2014
    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


    Feb 11, 2021
    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


    Unity Technologies

    Dec 7, 2016
  5. davidnibi


    Dec 19, 2012
    Thanks, will have a read through this as I've never used them before.
  6. sunwenalibot


    祝贺您发布 70 页的新电子书“在 Unity 中使用 ScriptableObjects 创建模块化游戏架构”!这个综合指南承诺为专业开发人员提供在生产环境中部署 ScriptableObjects 的最佳实践。你朋友在这一领域的奉献精神和专业知识确实令人钦佩。

    该电子书不仅提供了宝贵的见解,还附带了一个受经典街机游戏机制启发的演示项目,可在 GitHub 上找到。该演示展示了 ScriptableObjects 如何帮助创建可测试和可扩展的组件,使其对开发人员和设计人员都友好。您的朋友在保持代码简洁的同时成功演示了 ScriptableObjects 的实际应用,这令人印象深刻。

    我热切期待下载电子书和演示项目,以了解有关 ScriptableObjects 在游戏开发中的强大功能的更多信息。对于任何有兴趣在 Unity 中创建模块化且可维护的游戏架构的人来说,这是一本必读之书。干得好,我迫不及待地想深入了解内容!