question

paulucci-marco07 avatar image
paulucci-marco07 asked

GameServer in Client

Hello everyone. So, made a lot of advancements in understanding UnityNetworking and how the server is supposed to work. I'm running the server instance on the client for development and it's making my life much easier. So, to the questions:

1) Obviously, the client app isn't supposed to contain the server logic. Is it possible to build a client and server app safely from the same unity project? Any best practices?

2) More specific sub-question of the above one. When building an unity project, what happens to unused libraries or code/logic? Will Unity do a scan and ignore files that are not being called by scenes or scripts?

3) If not, is it possible to manually exclude certain code (so, i'd only build with the client code or server code)? And if not, at which point I assume I need two separate unity projects, any tips on that? Considering I cannot run two unity projects at once, it seems very difficult to do local testing.

4) If I build my app (that contains both client and local playfab server) - does the server actually work on devices such as ios/android? I've built my working app and tried on android emulator and it failed to connect, I haven't looked much into it yet (need a way to debug or see what's exactly happening) but figured I would ask just in case I'm wasting my time. Can someone maybe point me in the right direction of how I can efficiently solve/debug issues on app builds, that'd be appreciated (otherwise I guess I'm gonna make some UIText and print errors there).

I am aware many of these questions may be unity releated, but I've had much better experience in these forums instead. Thanks!

Custom Game Servers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

1) Yes, it's absolutely possible to have both in one project - our server sample shows just that (https://github.com/PlayFab/PlayFabGameServer).

2) Since we don't support Unity here, and they could change the behavior of their product from version to version, I'd really rather not have an authoritative statement here that could mislead people. Best to check the Unity forums for that answer.

3) See 2.

4) There's nothing that would prevent you from building an app that uses the Server API on iOS or Android. It's just that you really don't want to do this for anything other than internal tools that you keep tight control over, since if an end-user has access to the Server APIs, that means they have access to the Secret Key. And that gives them the ability to to very bad things to your title.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ashkan-saeedi-mazdeh avatar image
ashkan-saeedi-mazdeh answered

This question is not new and I understand here is not the place to solve unity issues but in the interest of someone who needs an answer for 2 and 3

2- Unity DOES exclude unused/unreferenced assets which are not in your build scenes list or resources folder but it doesn't exclude code normally. Stripping does exclude unused code paths but that should not be relied on for security related features IMHO since we are not sure what exactly it excludes and its behavior can change
3- you can use #if and defines to exclude code from certain builds. search for compilation directives of C#. Unity allows you to define them both in player settings and also using BuildPipeline API. Also 2018.3 and later include some server specific build option and a default define for it.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.