Netcode for Entities 1.0.17 HierarchyPrefabType missing reference in unity 2023.3

After installing the Netcode for entities, I’m getting:

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?)

2023 is not supported by the dots packages yet (soon™)

1 Like

Could you explain this, because ecs 1.0 is supported from what I’ve been doing.

https://discussions.unity.com/t/933505

From their development update a week ago

1 Like

Damn, this sucks! Would expect at least a work around or temp solution for those using 2023 version.

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.

It’s super easy to fix …

In your project, there’s a path:
"\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)

# ------------------------------------------------------
# PowerShell: Auto-Fix HierarchyDrawers.cs ::
# ______________________________________________________

$filePath = ".\Library\PackageCache\com.unity.netcode@1.0.17\Editor\Authoring\HierarchyDrawers.cs"
$pattern = "isReplicated = item.PrefabType != "
$replacement = "            isReplicated = item.PrefabType != Unity.Entities.Editor.Hierarchy.HierarchyPrefabType.None;"

# Ensure the file exists
if (-Not (Test-Path -Path $filePath)) {
    Write-Host "File not found: $filePath"
    exit
}

try {
    # Read the file content into an array
    $fileContent = Get-Content -Path $filePath

    # Use a loop to go through each line and replace the matching part
    for ($i = 0; $i -lt $fileContent.Length; $i++) {
        if ($fileContent[$i] -match $pattern) {
            $fileContent[$i] = $replacement
            break
        }
    }

    # Write the updated content back to the file
    Set-Content -Path $filePath -Value $fileContent
}
catch {
    Write-Host "An error occurred: $_"
}
1 Like

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 …)

2 Likes

*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.

As far as I can tell Unity already fixed this for you guys in 1.2?

Which is the only supported version of entities/netcode in Unity 2023 (2023.3.0b1+)

1.0.X is not supported and there are quite a few bugs in entities in 2023 on this version

Well, if they wanna hire me I’ve got my ears open! :smile:

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. :eyes:

What version of Unity? it won’t appear in any version earlier than 2023.3.0b1

1 Like

That’s why (2023.2) :smile:

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)

1 Like