#Switching build target to windows client causes compilation errors?

1 messages · Page 1 of 1 (latest)

novel merlin
#

I feel like i'm being stupid here.. But i can't seem to work this out.
It's exactly like i say in the above title... everything runs fine.. Linux server runs fine... compiles fine.. editor runs fine for testing...

But then i want to test on a 'standalone build' on my pc.. so i try to run a windows-build.. and i get this:

Assets\Scripts\Networking\Server.cs(102,27): error CS0246: The type or namespace name 'MultiplayAllocation' could not be found (are you missing a using directive or an assembly reference?)

Now obviously, this script runs on the 'server' so, it shouldn't really be necessary for the client...
..But, the script has not changed, only the target environment.. The 'using' statements i have written, are all the same... I mean have i missed an obvious 'option' here, or --can someone explain what i'm doing wrong / a solution?

thanks. notlikethis

novel merlin
#

nevermind, google always has the solutions. lol

south spear
#

For posterity, the Multiplay namespace should only be used on a dedicated server build target. Using #if UNITY_SERVER in your code will prevent the errors when switching platforms

novel merlin
# south spear For posterity, the Multiplay namespace should only be used on a dedicated server...

yes, this was exactly the solution, using those if statements around the 'problem causing' using statements and within the class itself, allowed me to keep the components/component references working on all builds...
..but when i went into a build that had compile errors, that was fixed...

..it was also a strange thing to see that switch 'build profile' seemed to transfer over to visual studio and it 'understood' which of those scripting-defines seemed relevant...

  • in the linux server build profile, everything was being interpreted / intellisense worked...
  • in the windows build profile, everything was greyed out, showing it was being bypassed... which was a nice indicator it worked...

However i would add.. on googling, some results suggested:
if UNITY_SERVER || UNITY_EDITOR
this did not actually work correctly...