Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Netcode for Entities 1.0.17 HierarchyPrefabType missing reference in unity 2023.3

Discussion in 'NetCode for ECS' started by jmgek, Nov 25, 2023.

  1. jmgek

    jmgek

    Joined:
    Dec 9, 2012
    Posts:
    96
    After installing the Netcode for entities, I'm getting:
    Code (CSharp):
    1. Library\PackageCache\com.unity.netcode@1.0.17\Editor\Authoring\HierarchyDrawers.cs(66,59): error CS0234: The type or namespace name ‘HierarchyPrefabType’ does not exist in the namespace ‘Unity.Hierarchy(are you missing an assembly reference?)
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,732
    2023 is not supported by the dots packages yet (soon™)
     
    jmgek likes this.
  3. jmgek

    jmgek

    Joined:
    Dec 9, 2012
    Posts:
    96
    Could you explain this, because ecs 1.0 is supported from what I've been doing.
     
  4. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,732
    jmgek likes this.
  5. dylan9007

    dylan9007

    Joined:
    Apr 21, 2018
    Posts:
    1
    Damn, this sucks! Would expect at least a work around or temp solution for those using 2023 version.
     
  6. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    873
    It is very easy to fix (and we will probably update the package later on to be compatible with 2023). But for now, unfortunately, you need to live with it.
     
  7. atcarter714

    atcarter714

    Joined:
    Jul 25, 2021
    Posts:
    55
    It's super easy to fix ...

    In your project, there's a path:
    "<project>\Library\PackageCache\com.unity.netcode@1.0.17\Editor\Authoring\HierarchyDrawers.cs"

    The offending line is around line 65 or 66, and begins with:
    `isReplicated = item.PrefabType != ...`

    Should be:
    `isReplicated = item.PrefabType != Unity.Entities.Editor.Hierarchy.HierarchyPrefabType.None;`

    (Note: Make it a local package and manually edit that line, and it'll build ... no guarantees other than it'll fix that specific compilation/build error and let it proceed -- what happens after that depends on your project/configuration and Unity itself.)

    If you have dev-ops and need a way to automate it:

    (Windows Powershell)
    Code (pwsh):
    1.  
    2. # ------------------------------------------------------
    3. # PowerShell: Auto-Fix HierarchyDrawers.cs ::
    4. # ______________________________________________________
    5.  
    6. $filePath = ".\Library\PackageCache\com.unity.netcode@1.0.17\Editor\Authoring\HierarchyDrawers.cs"
    7. $pattern = "isReplicated = item.PrefabType != "
    8. $replacement = "            isReplicated = item.PrefabType != Unity.Entities.Editor.Hierarchy.HierarchyPrefabType.None;"
    9.  
    10. # Ensure the file exists
    11. if (-Not (Test-Path -Path $filePath)) {
    12.     Write-Host "File not found: $filePath"
    13.     exit
    14. }
    15.  
    16. try {
    17.     # Read the file content into an array
    18.     $fileContent = Get-Content -Path $filePath
    19.  
    20.     # Use a loop to go through each line and replace the matching part
    21.     for ($i = 0; $i -lt $fileContent.Length; $i++) {
    22.         if ($fileContent[$i] -match $pattern) {
    23.             $fileContent[$i] = $replacement
    24.             break
    25.         }
    26.     }
    27.  
    28.     # Write the updated content back to the file
    29.     Set-Content -Path $filePath -Value $fileContent
    30. }
    31. catch {
    32.     Write-Host "An error occurred: $_"
    33. }
    34.  
     
    Last edited: Jan 17, 2024
    bugfinders likes this.
  8. atcarter714

    atcarter714

    Joined:
    Jul 25, 2021
    Posts:
    55
    Even if you don't do dev-ops/automation and are too lazy to manually edit files or have many to fix, you can save my pwsh script as a .ps1 script file and use it to instantly fix the problem. To run it just make sure you're in the project root directory (so it can find the path ".\Library\..." in the `Library` folder) and run it. Double-click will run it if you have pwsh configured to auto-run ps1 files, but you can pop open pwsh.exe and `cd` into your project and simply put:
    pwsh 'path-to-script\AutoFixNetcode.ps1'
    (Press [Enter] next of course, so it'll run ...)
     
    jmgek and bugfinders like this.
  9. jmgek

    jmgek

    Joined:
    Dec 9, 2012
    Posts:
    96
    ``isReplicated = item.PrefabType != Unity.Entities.Editor.Hierarchy.HierarchyPrefabType.None;``
    Perfect thank you, that's all I needed!

    It's amazing that a Unity Technologies employee can't even explain the problem and relies on community to solve their problems for them doing the job they should be doing.

    Wonder why the stock is so low.
     
  10. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,732
    Last edited: Jan 17, 2024
  11. atcarter714

    atcarter714

    Joined:
    Jul 25, 2021
    Posts:
    55
    Well, if they wanna hire me I've got my ears open! :D

    You might know why: Package Manager won't show me the Entities pre-release packages (i.e., 1.2) even with "Experimental Packages" ticked ... have to manually set it up locally, or use a more complex automation with git credentials to check it out and all that complicated foolishness when I just want it to resolve "normally" and let me reference prerelease Entities ... I have a Powershell module for Unity/Editor automation and it's a million times simpler to let Unity handle that. o_O
     
  12. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,732
    What version of Unity? it won't appear in any version earlier than 2023.3.0b1
     
    atcarter714 likes this.
  13. atcarter714

    atcarter714

    Joined:
    Jul 25, 2021
    Posts:
    55
    That's why (2023.2) :D
     
  14. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,732
    Yeah not a support version by Unity.
    The currently supported versions of the latest dots package are
    1.0 and 1.1 are supported on 2022.3.11f1+
    1.2 is supported on 2022.3.11f1+ and 2023.3.0b1+

    (and where i say + i mean only newer versions of the same major release)
     
    atcarter714 likes this.