Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Namespace Naming Related Issue (Resolved)

Discussion in 'Entity Component System' started by NT_Ninetails, Jul 8, 2022.

  1. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    191
    I had a namespace like this
    Code (CSharp):
    1. namespace MyNameSpace.Entity{
    2. //stuff
    3. }
    the ".Entity" cause a compilation error. Changing it to .EntityRealted fixed the issue.

    Unity 2021.3.5f1 Personal
    Entities 0.51.0-preview.32
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,011
    If you have two namespaces defining Entity as such:

    • MyNamespace.Entity
    • TheirNamespace.Entity
    And assuming the current class‘ namespace is the first one, then importing the other namespace like so:
    • using TheirNamespace;
    will lead to the issue you noticed. This is not a bug but a name clash. You can rename your namespace or prefix all other Entity uses with TheirNamespace.Entity or make a using alias like so:

    • using TheirEntity = TheirNamespace.Entity;
     
  3. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    760
    The namespace Entity collides with the struct Entity. Rename the namespace to Entities or some other name.
    It's not a Bug, it's how C# works.
     
    Anthiese likes this.
  4. NT_Ninetails

    NT_Ninetails

    Joined:
    Jan 21, 2018
    Posts:
    191
    First time I have run into this issue, thanks for clarifying.