jeffcampbellmakesgames / Entitas-Redux

An entity-component framework for Unity with code generation and visual debugging
MIT License
102 stars 13 forks source link

[QUESTION] How to setup a new assembly definition asset without loosing access to the generated code? #55

Closed matthiashermsen closed 3 years ago

matthiashermsen commented 3 years ago

I'm using Unity 2020.3.13f1 want to setup an assembly definition asset to pass it as a reference to the Play/Edit mode tests.

image

image

using JCMG.EntitasRedux;

namespace Sources.Features
{
    [Game]
    public sealed class AComponent : IComponent { }
}

image

Everything should be fine for now. You can find a stable version in this temporary reproduction repository branch

https://github.com/matthiashermsen/er-namespace-reproduction

Since I want to setup unit tests I have to create the assembly definition asset. To ensure all the code is picked up I created it here Asset/Sources/Sources.asmdef with this setup

image

Compile errors come up

image

I tried to generate the code again but unfortunately the errors remain. I pushed the broken version on this branch

https://github.com/matthiashermsen/er-namespace-reproduction/tree/broken

I would like to know how to solve this problem

jeffcampbellmakesgames commented 3 years ago

I don't think this is as much a question specific to ER than it is a general Unity question on how to use AssemblyDefinitions.

If you don't use AssemblyDefinitions, everything gets put into an appropriate auto-generated C# project based on whether it's runtime or editor code. All runtime code for example gets placed automatically for example in the CSharp-Assembly project if not in an AssemblyDefinition. EntitasRedux's own AssemblyDefinitions are auto-referenced by these C# Projects by Unity as part of it's auto-generated process.

If an AssemblyDefinition is created, it will only reference the AssemblyDefinitions the developer explicitly adds. That means unless the EntitasRedux AssemblyDefinitions are explicitly added, you will have compiler errors.

Using your example branch I created the same Sources AssemblyDefinition, added the EntitasRedux runtime AssemblyDefinitions, and hit Apply which resolved all open compiler errors.

image

matthiashermsen commented 3 years ago

I'm sorry, I didn't know that. Thanks a lot!