Call RPC from different project

Hi all,

I’m making a remote user interface for a particular Unity project. The user interface is also a unity project. I want to be able to connect from this UI project to the main project, and do RPC calls (e.g. reset player position, turn on/off certain features etc).

I’ve got server connection working, where the UI is the client and the original project is the server, but I’m stuck getting a matching Network View set up. I’ve looked at AllocateViewID, but I’m not sure who has to call this, and how to pass this ID to the other party, if there is no common Network View in the first place!

Any help will be appreciated…


OK, solved it, in a different way than the above answer. Here’s how:

  1. Instead of separate projects, I made separate scenes (one for our main project, as it was, and one for the remote UI) and export two different executables. This means I can still have a “thin” client, without all the massive assets of the main scene, while keeping all the scripts together, and avoiding duplicate code.

  2. When running as server, i.e. the main scene is started, it does a Application.LoadLevelAdditive(“remoteUI”), causing the remote UI scene to be loaded as well.

  3. The remoteUI scene has a script that checks whether it’s running as server or as client, by searching for a specific component that only exists in the main scene. If it’s running is server, it does nothing (except serve as a doorway for RPC calls simply by having the exact same NetworkView as the client scene, all through the standard Unity networking drag-and-drop). If it’s the client, it will display the client UI and do the requested RPC calls to the server.

I hope my description is clear enough for future seekers to understand what I did :slight_smile:

Unity’s networking is really meant to be the same client peer-to-peer(one peer hosts server) which is essentially how UDK does it too. Separate master server style applications is “out of the norm” implementation. We ran into this on a project we were doing at work a while back.

Here was our solution:

If you have Unity Pro, use C# and start learning socket programming (its pretty simple). Write a broker TCP/IP server and a shared plugin class library that defines your operation codes as bytes and interact that way. 0x01 may be fined to call SpawnPlayer() etc.

Here’s a basic tutorial/example: A TCP/IP Server written in C# - CodeProject

If you don’t have Unity Pro, you will need to have identical prefabs and scripts in both projects or your network views will never sync. Make sure you turn on Edit->Project Settings->Network->NetworkManager Debug Level = Full to aid debugging this on both clients. Making these sync between both projects is a maintenance nightmare, but necessary. Hindsight, I would have spent more time testing if it would work by having all those “shared” prefabs in an asset bundle and sync script code (via build events).

You can also look at Photon, however its Unity package (last time I looked) was all setup for game lobby->join a game style… which was not proper for simply trying to make a “player” client and an “admin/gm” client.

I need to have main page with categories and when user click on a specific category he will be redirected to the project related to this category and this project should be on server so that I will be able to make changes to it without making user to update his application? is that applicaple?

Thank you for help