Siccity / SerializableCallback

UnityEvent and System.Func had a child
MIT License
359 stars 53 forks source link

Fix UPM assembly definition files #20

Closed rfadeev closed 4 years ago

rfadeev commented 4 years ago

Summary

Fix not being able to use package via Unity Package Manager.

Details

When installing package via git following warnings are shown in editor console:

Script 'Packages/com.github.siccity.serializablecallback/Attributes/TargetConstraintAttribute.cs' will not be compiled because it exists outside the Assets folder and does not to belong to any assembly definition file.
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget, String[])
...
Script 'Packages/com.github.siccity.serializablecallback/Test.cs' will not be compiled because it exists outside the Assets folder and does not to belong to any assembly definition file.
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget, String[])

This is caused by missing assembly definition files in the repository. Following steps are done:

  1. Created Runtime folder and moved all non-editor code there (this follows Unity package layout convention) e1e5f9a3efe6d2027a3f647c6b506ab812b5a4d7
  2. Created assmebly definition files for Editor and Runtime folders 9c5e3bf94af645b6dc4835fb5a74fc613a173260
  3. Bonus fix: added package author info f1d8774c7937a83afee9282dff223e03d3669f8b

How to test

Add package to Packages/manifest.json as follows:

"com.github.siccity.serializablecallback": "https://github.com/rfadeev/SerializableCallback.git#fix-upm-asmdef",

Open Unity project, check no warnings are shown after package import and check package code can be used.

Things to consider

Moving package code from global namespace can be beneficial in the long run to avoid name clashes. Though to use the package one should add using directive to their source code.

Closes #19