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?)
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.
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: $_"
}
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 …)
*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.
Well, if they wanna hire me I’ve got my ears open!
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.
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)