Search Unity

Custom Packages Assembly issue

Discussion in 'Scripting' started by francescocagnetta, Jun 18, 2019.

  1. francescocagnetta

    francescocagnetta

    Joined:
    Jun 11, 2018
    Posts:
    13
    Hi all,

    I'm struggling with this problem:

    pre:
    I made a custom package which includes scripts, a couple of models, some textures and two unity scenes.
    I added it to the package manifest of a blank project and it downloaded it immediately.

    problem:
    when I open the scenes from the custom packages, all the scripts on the gameobjects have the warning "The associated script cannot be loaded. Please fix any compile errors and assign a valid script."

    ***EDIT: this is what I see in console for each script of the custom package:
    "Script Packages/xxx/xxx.cs' will not be compiled because it exists outside the Assets folder and does not to belong to any assembly definition file.

    Of course, there aren't errors in the scripts. I think it is a problem of Assembly definition, but I don't really know how to proceed to fix.

    Any advice?
     
    Last edited: Jun 18, 2019
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    In packages, you can't use scripts from your project, only vice versa. Asset bundles are packages for scenes if any.
     
  3. francescocagnetta

    francescocagnetta

    Joined:
    Jun 11, 2018
    Posts:
    13
    Hi palex, sorry I can't get the point. I am trying to use "things" from the package in a blank project. What's wrong with it?
     
  4. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    I mean, are you scenes in package referencing your scripts from project?
     
  5. francescocagnetta

    francescocagnetta

    Joined:
    Jun 11, 2018
    Posts:
    13
    I tried adding the namespace declaration to one of the scripts and now it is recognized correctly. Is it correct saying that scripts in custom packages need to include the namespace declaration?
     
  6. francescocagnetta

    francescocagnetta

    Joined:
    Jun 11, 2018
    Posts:
    13
    No no, the scenes only use scripts from the package itself
     
  7. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Have you tried reimport all ?
     
  8. francescocagnetta

    francescocagnetta

    Joined:
    Jun 11, 2018
    Posts:
    13
    Yes. Tbh, I think I am missing a piece of knowledge :/ I can't see why it does not work
     
  9. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Sometimes unity just glitches. Looks like refs in your scene became broken because you moved scrit to another assembly. I think deleting library folder and reloading your project may help. But it may not.
     
  10. francescocagnetta

    francescocagnetta

    Joined:
    Jun 11, 2018
    Posts:
    13
    delete the Library folder seems have fixed O.O
     
  11. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    Inside Library folders there is compiled assemblies cache. The script itself was compiled, so unity expected threre's assembly containing that script in that cache. But since you moved the script to package (different assembly) along with it's metafile, i believe, unity was looking for that script in non-existant assembly. You deleted the cache, it was rebuilt, and everything works as it should.
     
    kiber_ likes this.
  12. francescocagnetta

    francescocagnetta

    Joined:
    Jun 11, 2018
    Posts:
    13
    understood. Thanks for your help. I'll update here in case of other issues.