Simple sharing example of gameObjects
Hello,
in the Spawn sharing example i saw that it's possible to sharespawned objects. Now i want to be able to share GameObjects which i added to the scene in Unity without the SpawnManager but i am still looking for a easy solution. I know that it should be possible by changing CustomMessage but i hoped there is something which is more simple like adding a component to the GameObject.
Some documentation about that would be very helpful. Thanks a lot.
Dominic
Dude, I just spent the last 3 days updating the docs...
I would advise against expanding custom messages and use the sync & spawning classes provided. Also, take a look at the SharingSpawnTest scene.
😀Thanks for your work and i swear that read the docs.
The problem is that it's hard to maintain a complex scene without a GUI.
And especially if you need to add sharing to a existing project its not the best idea to create everything in code with the spawn mechanism.
I hoped there is something simple like adding a component to a gameobject which i did not see in the existing docs...
No worries, a tutorial would really do nicely.
The latest updates to the sharing system did add a way to visualize the sync objects on the root via the SharingStage.

I tried some stuff... I hoped i could solve it by adding a SyncObject to my MonoBehaviour, but i think this will not work as there will be different instances of the SyncObject on every client.
using System.Collections;
using System.Collections.Generic;
using HoloToolkit.Unity.InputModule;
using UnityEngine;
public class TransformSync : MonoBehaviour, IFocusable {
public SyncGameObject mySyncObject = new SyncGameObject();
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Debug.Log(mySyncObject.myInt.Value);
}
public void OnFocusEnter()
{
mySyncObject.myInt.Value = 10;
}
public void OnFocusExit()
{
mySyncObject.myInt.Value = 5;
}
}
I also tried to SyncData on the SyncGameObject but i have to be honest that i did not understand the sharing system yet....
The instance is carried over to the other clients and you shouldn't have to spawn new instances of the same object on each. The sharing system will handle that for you by notifying the other clients to spawn an instance in their games via the prefab spawn manager.
Take a look at how the sharing spawn test scene works.
I had a look at the test scene, but do you really think it's the best way to bundle the used objects into prefabs and place them progammatically instead of modeling them in the scene in Unity?
Maybe you are right and this makes also sense from the perspective that a room is dynamic and placing the objects in the Editor means they can later be inside a wall or outside the spatial mapping.
If i want to set of objects initially in my room and sync them i create prefabs for every object and the first user who joins initializes the placement of the objects in the room.
Yeah, most likely the environment your users are going to be interacting in will be very different from place to place. It's better to dynamically create your objects because of this very reason.
Doesn't help that the test scene doesn't work on device.
I was able to get this working pretty well, but kept getting duplicate objects when I only wanted a single one haha.
I plan up updating the two new sharing scenes in the near future https://github.com/Microsoft/HoloToolkit-Unity/issues/494
By the way.... Wouldn't it always be better to use the UNET protocol instead of the Hololens sharingserver..?
Depends on your use case. UNet is a paid service offered through Unity, where as the sharing service is open source and hosted on your own equipment.
@HodgsonSDAS - Match making is the only paid portion of UNET, IIRC.
@DominicBoettger - Having used HoloToolkit.Sharing and UNET, both are viable options for HoloLens shared experiences.
Sure if it's just in test mode. Switching to live mode even at 200 Concurrent users is $$$$

UNET is the name of Unity's current generation of networking components. I.e., it's an API. Matchmaker is their online match making and server system. We use UNET based networking a lot and it works just fine on private LAN and WAN. The trick part is connecting multiple devices over WAN. You need some sort of NAT punch-through or a server that is visible on WAN ... that's where Matchmaker comes in, and that's what they charge for.
I agree Matchmaker is a pricey, but UNET is definitely a free part of Unity and Unity Pro.
Yes, everything else doesn't make any sense cause in the local network there are only broadcasts for the connections and it also works without any WAN connection. In my oppinion there is no option to charge for UNET when used in the local network.
Thanks for the clarification guys. Goes to show my lack of knowledge of UNET, haha.