Search Unity

defaultReferences meta not being imported with custom package

Discussion in 'Package Manager' started by hugeandy, Apr 30, 2019.

  1. hugeandy

    hugeandy

    Joined:
    Nov 2, 2016
    Posts:
    131
    Hi,

    I have been creating a few packages over the last few weeks and I must say it's a great system so far!
    However there is one thing however that is catching me out:

    We have a custom editor window (a class extending EditorWindow) in the Editor section of our package.
    This class has a public reference to a ScriptableObject type, which we use for storing settings for the editor window.

    In order for the EditorWindow class to easily find the settings file (and to avoid searching for it after every refresh), I have the ScriptableObject asset dragged into the Import Settings for the EditorWindow script. Looking at the meta file for the EditorWindow script shows that defaultReferences correctly has the settings asset reference.

    This works great, and every time I open the window in the package dev project, it opens correctly and uses the settings asset as expected.

    Now moving over to an actual project which has our package imported into it:
    When we open the editor window, it throws null ref exceptions as the settings file is missing. Looking at the script in the packages folder shows that the reference is indeed empty (not missing). Looking at the meta file shows an empty defaultReferences array now.

    Is the defaultReferences a supported feature? If not: will it be in the future? And if double not: what is a good way to get reference to the settings asset?

    Cheers,
    Andy
     
  2. erick_unity

    erick_unity

    Unity Technologies

    Joined:
    Jan 4, 2017
    Posts:
    41
    hi Andy, I've sent your question to a couple of teams, I'll get back to you as soon as I hear something back.
     
  3. erick_unity

    erick_unity

    Unity Technologies

    Joined:
    Jan 4, 2017
    Posts:
    41
    Andy, it's very important that you bundle all the meta files with your package, as otherwise, the editor will generate a new one which will affect references. Do all files in your package have the associated meta file included in the package as well?
     
  4. hugeandy

    hugeandy

    Joined:
    Nov 2, 2016
    Posts:
    131
    Hey Erick,

    Thanks for your replies. Yes, I've made sure all the meta files are included with the package, and have ensured that the files in question have the same ids in both the dev project and the game project
     
  5. erick_unity

    erick_unity

    Unity Technologies

    Joined:
    Jan 4, 2017
    Posts:
    41
    Hi @hugeandy , i'm terribly sorry, i didnt yet receive a good answer to this specific problem. My suggestion would be to file a bug, and we'll make sure it ends up in the right team's hands. Do you have a workaround in the meantime?
     
  6. hugeandy

    hugeandy

    Joined:
    Nov 2, 2016
    Posts:
    131
    No worries. I started trying to repro in a clean package/project this morning and found it was working fully as expected, so I started digging deeper.

    I looked at the files our Verdaccio server had stored for the latest version of the package in question and found that the meta file for the settings asset had no entries in the defaultReferences array.
    So I went into the package dev project, removed the reference, saved, published to verdaccio, and then readded the reference, saved and published again. This now seems to have given everything a kick and it's now working!

    So we're all sorted now - thanks for your help!

    Andy