Custom Packages Assembly issue

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?

In packages, you can’t use scripts from your project, only vice versa. Asset bundles are packages for scenes if any.

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?

I mean, are you scenes in package referencing your scripts from project?

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?

No no, the scenes only use scripts from the package itself

Have you tried reimport all ?

Yes. Tbh, I think I am missing a piece of knowledge :confused: I can’t see why it does not work

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.

delete the Library folder seems have fixed O.O

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.

1 Like

understood. Thanks for your help. I’ll update here in case of other issues.