MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Simple sharing example of gameObjects

Open DominicBoettger opened this issue 9 years ago • 18 comments

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

DominicBoettger avatar Feb 01 '17 20:02 DominicBoettger

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.

StephenHodgson avatar Feb 01 '17 21:02 StephenHodgson

😀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...

DominicBoettger avatar Feb 02 '17 00:02 DominicBoettger

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. image

StephenHodgson avatar Feb 02 '17 14:02 StephenHodgson

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....

DominicBoettger avatar Feb 02 '17 14:02 DominicBoettger

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.

StephenHodgson avatar Feb 02 '17 14:02 StephenHodgson

Take a look at how the sharing spawn test scene works.

StephenHodgson avatar Feb 02 '17 14:02 StephenHodgson

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.

DominicBoettger avatar Feb 02 '17 15:02 DominicBoettger

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.

StephenHodgson avatar Feb 02 '17 15:02 StephenHodgson

Doesn't help that the test scene doesn't work on device.

StephenHodgson avatar Feb 09 '17 22:02 StephenHodgson

I was able to get this working pretty well, but kept getting duplicate objects when I only wanted a single one haha.

StephenHodgson avatar Feb 09 '17 22:02 StephenHodgson

I plan up updating the two new sharing scenes in the near future https://github.com/Microsoft/HoloToolkit-Unity/issues/494

StephenHodgson avatar Feb 14 '17 20:02 StephenHodgson

By the way.... Wouldn't it always be better to use the UNET protocol instead of the Hololens sharingserver..?

DominicBoettger avatar Feb 16 '17 18:02 DominicBoettger

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.

StephenHodgson avatar Feb 16 '17 18:02 StephenHodgson

@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.

Ziugy avatar Feb 16 '17 23:02 Ziugy

Sure if it's just in test mode. Switching to live mode even at 200 Concurrent users is $$$$ image

S-Hodgson-MMOARgames avatar Feb 17 '17 01:02 S-Hodgson-MMOARgames

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.

calebcannon avatar Feb 17 '17 01:02 calebcannon

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.

DominicBoettger avatar Feb 17 '17 01:02 DominicBoettger

Thanks for the clarification guys. Goes to show my lack of knowledge of UNET, haha.

StephenHodgson avatar Feb 17 '17 14:02 StephenHodgson