Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    Dismiss Notice

Resolved Editor UI for "Inventory Items" is slow

Discussion in 'Game Foundation' started by shaomang, Jul 5, 2020.

  1. shaomang

    shaomang

    Joined:
    Mar 30, 2014
    Posts:
    5
    Hello community,

    I'm not sure this is a bug from GF or Unity UI. In my project, It takes one to few seconds every time when I'm trying to edit any value in the Inventory Items (the JSON Detail or etc.). In the profiler under play-mode, it causes a 500ms spike in EditorLoop even for a mouseover on the UI.

    Seems the problem started from 0.4, and updating to 0.6 did not solve the problem. I'm using 2020.2.0a, most packages are the latest preview version.
     
  2. shaomang

    shaomang

    Joined:
    Mar 30, 2014
    Posts:
    5
    I tried to edit in an empty scene but no difference. This only happens if JSON detail is added to the entry.

    Anyone is having the same problem or just me? Please, the asset is almost unusable.
     
  3. erika_d

    erika_d

    Unity Technologies

    Joined:
    Jan 20, 2016
    Posts:
    406
    Hi @shaomang,

    Thanks for the report, this is a known issue that the json detail can slow the editor window down (you can see it in the first bullet point of our latest known issues update https://docs.unity3d.com/Packages/com.unity.game.foundation@0.6/manual/KnownIssues.html).

    There is not currently a plan to fix the json detail editor display as we're planning on transitioning the json detail use case to the static properties field. Will Static Properties work for the things you're storing in the JSON detail right now?
     
  4. shaomang

    shaomang

    Joined:
    Mar 30, 2014
    Posts:
    5
    Hi Erika,

    Thanks for the reply and sorry for missing the announcement.

    Because there are many entries in my case, swapping to the new approach is a bit difficult and will involve changes in the game system. But judging from the tutorial, personally I still prefer JSON detail since I can simply combine the structs and pass them directly in my game, instead of typing keys for each new item over and over again, it's also much easier to add a new property later across a category.

    Maybe I missed something again, but I fail to understand how Static Properties is better than JSON detail.
     
    mingz-unity likes this.
  5. erika_d

    erika_d

    Unity Technologies

    Joined:
    Jan 20, 2016
    Posts:
    406
    Hi @shaomang,

    Thanks for the feedback on how you've been using the JSON detail, that's good to know. I've passed that info and your question about the benefits of static properties on to the folks working on the static properties/json detail switch.

    As far as changing to the new approach involving changes to your game system, we totally recognize that it can be quite frustrating to have to refactor parts of your code because of changes we make, and we're trying to avoid it when possible, but we also want to make the best long term decisions for the product features, which does sometimes result in some fundamental changes. It's a preview package still for that reason, as we recognize once it is out of preview, fundamental changes like that become a bit more difficult. We appreciate your patience and feedback while we work through the development process though!
     
    shaomang likes this.
  6. antoine-agthe_unity

    antoine-agthe_unity

    Unity Technologies

    Joined:
    Jun 6, 2019
    Posts:
    7
    Hello @shaomang,
    Thanks for participating in making Game Foundation better.

    As @erika_d said, we have known issues with the
    JSONDetail
    .
    The most visible is definitely the Editor UI performance.
    At the moment, the UI redraws too much, and the drawing process is too heavy.
    We've decided not to fix that yet because we're switching to
    Static Properties
    .

    That being said, this switch is not due to the UI performance reason.
    We want properties to be part of the DNA of a definition, while
    Details
    look more like something optional.
    JSONDetail
    is still available for backward compatibility reasons but would be deprecated soon.

    As you've noticed,
    Static Properties
    don't have the same level of support for types and structures.
    We're in the process of searching for the best serialization strategy for the fields, and that's the reason why we regressed to simple types for this version of
    Static Properties
    .

    We use this system to define:
    -
    mutable properties
    of inventory items
    -
    static properties
    of all the definitions of the catalog
    - the
    Game Parameters
    too.

    The goal is to have one system fitting all the data definition of Game Foundation.

    The most challenging part is to be sure that the strategy we're using can fit with backend systems (that is also why handling asset hard references is not possible, and
    AssetsDetail
    uses paths as
    string
    instead of the assets directly).

    One of the benefit of
    JSONDetail
    was the ability to define
    CustomData
    .
    This is something we'd like to support in a better way, as it takes too much work for the developer to use it.
    Using a
    Dictionary<string, object>
    may be flexible, but it allocates too much due to boxing/unboxing, and the developer has to write the conversion methods for each structure he creates.

    Sorry to hear that it makes some noises in your game code.
    Using a Preview package comes with some risks, so my advice to you is that you should probably adopt some of the Clean Architecture concepts in order to depend less on the current API of Game Foundation.
     
    shaomang and erika_d like this.
unityunity