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.
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?
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.
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.