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

Where did custom detail definitions go in version .4?

Discussion in 'Game Foundation' started by Bivens32, Apr 28, 2020.

  1. Bivens32

    Bivens32

    Joined:
    Jul 8, 2013
    Posts:
    36
    I was planning on using custom detail definitions for many different concepts in my game. Now it seems those are gone and also the Game Items section. Now everything is an Assets Detail. The API for getting asset details is fine, but having to set up everything using string paths is just a pain. Can't preview what the asset is in the inventory editor, can't change the location of the asset without breaking everything, entering an asset path is tedious and slow. At least make it where it opens an asset browser and automatically selects the correct path. I really hope this will be changed because it's really not sustainable for practical game item counts.
     
  2. Katoha

    Katoha

    Joined:
    Feb 17, 2020
    Posts:
    5
    Hi,
    I am running .4 and have access to custom definitions.

    Also if you define your type you can get an asset browser by default.

    Code (CSharp):
    1. public class TokenTypeDetailEditorDefinition : BaseDetailDefinition
    2. {
    3.     public TokenType tokenType;
    4.  
    5.     public override string DisplayName()
    6.     {
    7.         return "Token Type";
    8.     }
    9.  
    10.     public override UnityEngine.GameFoundation.BaseDetailDefinition CreateRuntimeDefinition()
    11.     {
    12.         return new TokenTypeDetailDefinition(tokenType);
    13.     }
    14. }
     
    Bivens32 likes this.
  3. mingz-unity

    mingz-unity

    Unity Technologies

    Joined:
    Oct 12, 2017
    Posts:
    63
    @Bivens32 Thanks for your question and happy to provide a deeper explanation around the recent changes introduced in v0.4.

    Firstly, I'd say that Game Foundation is evolving quickly (as you know it’s a preview package). We’ve introduced a lot of improvements in v0.4, and as a result a few changes in the underlying systems also took in place. I’ll answer the two big changes you mentioned below:

    AssetDetail

    We know that there are some use cases where AssetsDetail is not as intuitive as it could be, and we plan to address that in a future release.

    Here’re some more details on the challenges we’re trying to address: memory usage, and serialization.

    For memory usage, the problem with the previous integration is related to how Unity resolves dependencies and loads resources. If you have a hard reference to any asset in the catalog, then loading the catalog also loads all the referenced assets. It can use a lot of your memory (even more than you have, leading to game crashes), and it takes longer to load. For very small games, it's not really a problem because all of the assets can fit in the memory. For bigger games, that's another story.

    At the moment, the only source of assets the AssetDetail supports are the Resources folders. While this is not the ultimate or perfect solution, it's something Unity provides by default.Better UX is something we are always thinking about, but we also have other plans (see later in this post).

    For the serialization, it is related to Unity Serialization. Inside Unity, referencing assets is easy- it only takes a member in your class, as long as your class is Serializable. For a basic setup of Game Foundation, using the default GameFoundationDatabase, it works.

    But one goal of Game Foundation is to be able to work with backend systems. In this release, we added a reference implementation of a ChilliConnect adapter that makes it possible for Game Foundation to work with a backend.

    In this configuration, your catalog doesn't come from Unity anymore, but from your backend system (for ChilliConnect, you can check here: https://docs.chilliconnect.com/guide/catalog/)

    Yet those backend systems don’t understand the internal dependency resolution that Unity uses in its serialization.That means, having a hard reference to an asset in the catalog doesn't make this catalog serializable for external backends.

    With AssetsDetail, what we serialize is the path to the asset. It is a string value that all of the backend systems can store, and distribute. The Resources API is far from being the ultimate solution for liveops, as we can't reference assets from asset bundles, and it takes the game to be updated with new content.This implementation is a short term solution, sufficient for testing Game Foundation, but not production ready.

    We've started discussing the possibility to rely on Addressables as it provides a more flexible solution to reference assets.


    Custom Detail

    CustomDetail that we introduced in earlier versions face some serialization problems today as we move onto a more complex data persistent solution.

    If developers create their own custom detail with code, there is no way for us to guarantee that this custom detail will be serializable, because we cannot support all of the Unity Serialization features that we need to be compliant with third party backend systems limitations. We've replaced the CustomDetail by JsonDetail and we're currently investigating a better solution (so you can expect some changes soon).

    In the meanwhile, the new JsonDetail exposes field types we can serialize so you can add arbitrary fields to your item definition.
     
    erika_d and Bivens32 like this.