Search Unity

Why packages scripts won't compile?

Discussion in 'Package Manager' started by AccentDave, Jan 16, 2020.

  1. AccentDave

    AccentDave

    Joined:
    Nov 16, 2015
    Posts:
    43
    This may be a noob question, maybe I'm missing something basic, but as I try to create a package (my favorite little utility scripts), those scripts are unusable. Trying to drop a behavior from my package onto a game object gives me: "Cant Add Script: Can't add script component 'HandyThing' because the script class cannot be found. Make sure blah blah blah "
    Well, I cut my sample down to one script. No naming errors. No errors or warnings in the console. If I drag the script under Assets, it works fine, but of course breaks my package (no?).
    I thought maybe this was some sort of protection thing, but I dumped a texture into my package, and I was able to use that on a Material no problem.
    What am I missing? Do I have to have an asmdef file?
     
  2. AskCarol

    AskCarol

    Joined:
    Nov 12, 2019
    Posts:
    234
    Sorry you are experiencing this issue! Which version of Unity are you using?
     
  3. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,065
    Yes, Assembly Definitions are required for packages, your scripts won't work otherwise.

    @AskCarol Would be great if Unity could add a warning for (local) packages that contain scripts but no Assembly Definition.
     
  4. AskCarol

    AskCarol

    Joined:
    Nov 12, 2019
    Posts:
    234
    Thanks for the feedback. Definitely something I'll pass on to the scripting team to improve your experience.
     
  5. sabint

    sabint

    Joined:
    Apr 19, 2014
    Posts:
    26
    I wandered around for a whole week before realizing it was the assembly definition that was missing. An accurate error message would definitely be helpful. Still happens in 2019.4.17f1 and 2020.0.1f1
     
  6. UnityMaru

    UnityMaru

    Community Engagement Manager PSM

    Joined:
    Mar 16, 2016
    Posts:
    1,227
    Are you able to provide a screenshot of this with the version number intact? Our team's having trouble reproducing this on their end.
     
  7. Tony_Max

    Tony_Max

    Joined:
    Feb 7, 2017
    Posts:
    351
    Still not present in manual
     
  8. UnityMaru

    UnityMaru

    Community Engagement Manager PSM

    Joined:
    Mar 16, 2016
    Posts:
    1,227
    From talking with the team, they do feel that it is mentioned in the documentation several times. Also, the warning system is already in place. Are there strong feelings that it should be amended in someway to be clearer, or provide more context?
     
  9. thomasvaniseghemSB

    thomasvaniseghemSB

    Joined:
    Sep 15, 2022
    Posts:
    13
    Years later I stumbled upon the same problem. This is not clear at all in the documentation unfortunately. Using 2021.3.9f.