Search Unity

Question Main Asset in ScriptableObject asset

Discussion in 'Scripting' started by Andrew-Carvalho, Jul 16, 2020.

  1. Andrew-Carvalho

    Andrew-Carvalho

    Joined:
    Apr 22, 2013
    Posts:
    45
    I have a ScriptableObject asset that has a few ScriptableObjects stored at the same path (same file). Specifically, I have a container asset that I can add additional assets to using a custom inspector. This is all working as intended.

    When I first create the asset, the container asset is the first and therefore main asset. Unfortunately, if I duplicate the asset or even rename it, the main asset and one of the sub assets swap (and also mess up some object names). While I'm aware that there isn't anything special about main assets, I do find it weird that duplication doesn't keep the same hierarchy in the project view.

    From the docs, emphasis mine:
    How exactly is Unity deciding the importance of types compared to one another, and is there any way to influence this?
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
  3. Andrew-Carvalho

    Andrew-Carvalho

    Joined:
    Apr 22, 2013
    Posts:
    45
    Yup, looks like the same issue. Good to know it's relatively recent because I've never noticed this before and thought I was forgetting something important.

    I did some experimenting and did notice a pattern in how types are prioritized, though it's not very promising in terms of being easily fixable.

    Starting with the main asset and going down child assets, they get reordered by the name of the type, alphabetically. I don't really feel like making up bad names for my types just to make this work, so I guess I will live with it for now. It would be nice if Unity could put in a quick fix to make it sort alphabetically by the name of the asset instead, since that is easier to apply a workaround to.