jeffcampbellmakesgames / Entitas-Redux

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

[BUG] Entity.CopyTo and Context.CloneTo methods not generated when zero components created #27

Closed pmikstacki closed 3 years ago

pmikstacki commented 3 years ago

Describe the bug After Generation Unity throws

_Assets\Generated\Game\GameContext.cs(40,10): error CS1061: 'GameEntity' does not contain a definition for 'CopyTo' and no accessible extension method 'CopyTo' accepting a first argument of type 'GameEntity' could be found (are you missing a using directive or an assembly reference?)

Assets\Generated\Input\InputBlueprintBehaviour.cs(38,12): error CS1061: 'InputEntity' does not contain a definition for 'CopyComponentTo' and no accessible extension method 'CopyComponentTo' accepting a first argument of type 'InputEntity' could be found (are you missing a using directive or an assembly reference?)

Assets\Generated\Game\GameBlueprintBehaviour.cs(38,12): error CS1061: 'GameEntity' does not contain a definition for 'CopyComponentTo' and no accessible extension method 'CopyComponentTo' accepting a first argument of type 'GameEntity' could be found (are you missing a using directive or an assembly reference?)

Assets\Generated\Game\GameBlueprint.cs(38,12): error CS1061: 'GameEntity' does not contain a definition for 'CopyComponentTo' and no accessible extension method 'CopyComponentTo' accepting a first argument of type 'GameEntity' could be found (are you missing a using directive or an assembly reference?)

Assets\Generated\Input\InputBlueprint.cs(38,12): error CS1061: 'InputEntity' does not contain a definition for 'CopyComponentTo' and no accessible extension method 'CopyComponentTo' accepting a first argument of type 'InputEntity' could be found (are you missing a using directive or an assembly reference?)

Assets\Generated\Input\InputContext.cs(40,10): error CS1061: 'InputEntity' does not contain a definition for 'CopyTo' and no accessible extension method 'CopyTo' accepting a first argument of type 'InputEntity' could be found (are you missing a using directive or an assembly reference?)_

Unity Version: Unity 2020.1.8f

To Reproduce Steps to reproduce the behavior:

  1. Create new Unity Project
  2. By using upm-cli Add Entitas Redux Package and NaughtyAttributes Package(Idk if relevant but could be)
  3. Follow the hello world tutorial
  4. Generate project files

Expected behavior Stuff Generates without errors.

Screenshots Assembly Definitions for Entitas Redux are autoreferenced so it is not the case of generic null reference. image image

Additional context I also use URP in my project. I even created a new project but the problem persists.

jeffcampbellmakesgames commented 3 years ago

@pmikstacki I've just reproduced this locally and can see what the issue is. Following the tutorial, the first code-generation event takes place before it's directed the user to create any components, but the way code-generation is setup for components it must not handle the case to generate either the CopyTo or CopyComponentTo methods if there are not any components assigned to that context. The ideal outcome should be in this case that it generates empty methods with these signatures for a context/entity that does not have any components assigned.

There is a workaround you can use for now by:

[Game, Input]
public class EmptyComponent : IComponent {}

This should put you at a point where everything compiles and you can proceed with the Hello World tutorial.

In the meantime I will adjust the title of the bug and assign it for a release for the near future.

jeffcampbellmakesgames commented 3 years ago

This has been resolved in a fix merged to develop.