Hello everyone.

We have decided to phase out the Mixed Reality Forums over the next few months in favor of other ways to connect with us.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

The plan between now and the beginning of May is to clean up old, unanswered questions that are no longer relevant. The forums will remain open and usable.

On May 1st we will be locking the forums to new posts and replies. They will remain available for another three months for the purposes of searching them, and then they will be closed altogether on August 1st.

So, where does that leave our awesome community to ask questions? Well, there are a few places we want to engage with you. For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality. If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers. And always feel free to hit us up on Twitter @MxdRealityDev.

Synchronization System, what am I doing wrong?

chiddaanchiddaan
edited August 2017 in Questions And Answers

As it says, in synchronization system, the variables from SyncModel will always have same values for different users. So to test that, I created a small scene that uses sharing service for everyone to join the session.

UI: 2 buttons to increase and decrease the value of integer shown in text field
This integer is the SyncInt from SyncModel. Valtext is associated with the textbox between two buttons, with default text "Val"

Observed: when one user changes the value using buttons, it's not changed for other users.
Expected: when one user changes the value using buttons, it's changed for other users.

I am guessing that I am not using it the way it's supposed to be used, what am I doing wrong?

using UnityEngine;
using HoloToolkit.Sharing.SyncModel;
using UnityEngine.UI;

public class SyncObjTest : MonoBehaviour {

    public Text valText;
    SyncInteger synInt = new SyncInteger("");
    // Use this for initialization
    void Start () {
        synInt.Value = 5;
    }

    // Update is called once per frame
    void Update () {
        valText.text = synInt.Value.ToString();
    }

    public void addPressed()
    {
        //when Add button is pressed
        synInt.Value += 1;
    }

    public void subPressed()
    {
        //when Sub button is pressed
        synInt.Value -= 1;
    }
    public void onExit()
    {
        Application.Quit();
    }
}

Answers

  • @HoloSheep any thoughts, sir?

  • james_ashleyjames_ashley ✭✭✭✭

    @chiddaan ,

    This looks right. Sorry to ask the obvious, but are your sharing service and sharing stage configured correctly? Does the sharing service command window say that both devices are successfully added to the the sharing session?

    (From the readme:)

    Ensure you have the following capabilities set in Player Settings -> Windows Store -> Publishing Settings -> Capabilities:
    1.SpatialPerception
    2.InternetClientServer
    3.PrivateNetworkClientServer
    4.Microphone capabilities

    Install or run the server instance.

    Troubleshooting


    •Double check the Server Address on your sharing stage component in your scene matches the address shown in the sharing service console.
    •Make sure all devices are connected to the same Wireless Local Area Network.
    •Ensure all firewall settings are correct. Windows firewall gives you options to enable/disable by network type (private, public, home), make sure you're enabling the firewall for your connection's type.

    James Ashley
    VS 2017 v5.3.3, Unity 2017.3.0f3, MRTK 2017.1.2, W10 17063
    Microsoft MVP, Freelance HoloLens/MR Developer
    www.imaginativeuniversal.com

  • This can be soooooooo confusing!

    What is probably happening is someone who isn't the server is changing the value. So you have to ask the server to change the value for you. To do that you need to add a [Command]. But that's not all! In order to call a 'Command' the object calling the command must have what Unity calls 'localPlayerAuthority'. If you don't have authority for the object, you can't call the command. This is a lot to wrap your head around.

    The easiest solution I've found, and it isn't my favorite because it won't scale well, is to route commands through the PlayerController script for the local player.

    It looks something like:

    //In the PlayerController script:
    public SyncObjTest mainMenu; // set in inspector maybe...
    [Command]
    void CmdIncrement()
    {
    mainMenu.AddForReal();
    }

    public void Increment() // To be honest I don't know if you can just call CmdIncrement() directly from SyncObjectTest.
    {
    CmdIncrement();
    }

    //and in the SyncObjectTest script something like:
    public void AddPressed()
    {
    localPlayerController.Increment();
    }

    public void AddForReal()
    {
    syncInt.Value+=1;
    }

    ===
    This post provided as-is with no warranties and confers no rights. Using information provided is done at own risk.

    (Daddy, what does 'now formatting drive C:' mean?)

  • @chiddaan Any news on this topic?
    I also need some info on how it works.
    I posted a new message here https://forums.hololens.com/discussion/9894/howto-use-holotoolkit-syncmodel/p1?new=1

Sign In or Register to comment.