Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

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.

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, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.

sending a game object name through custom messages in Sharing of holograms

edited December 2016 in Questions And Answers

I am working on a code where i want to pass the name of the game object via custom messages and send it to all other users in the sharing service so that they can spawn the game object. The code goes as follows:

For sending the message:
script 1 :

custom messages:

public void SendGameObj(GameObject obj)
                // If we are connected to a session, broadcast our head info
                if (this.serverConnection != null && this.serverConnection.IsConnected())
                    // Create an outgoing network message to contain all the info we want to send
                    NetworkOutMessage msg = CreateMessage((byte)TestMessageID.clicked);

                    //Appending a gameobj to the message
                    AddGameObj(msg, obj);

                    // Send the message as a broadcast, which will cause the server to forward it to all other users in the session.

**and **

void AddGameObj(NetworkOutMessage msg, GameObject obj)
       // Debug.Log(obj.name);

I assume this should write the message in and send it to all users

**Now while receiving :
In another script's start method : **

 CustomMessages.Instance.MessageHandlers[CustomMessages.TestMessageID.clicked] = this.OnGameObjIdRcv;

and the method :

 void OnGameObjIdRcv(NetworkInMessage msg)

        temp = GameObject.Find(CustomMessages.Instance.ReadGameObjName(msg));

**and the method which spawns the game object : **

 void SpawnObjforAllClients()
        spawnPosition = GameObject.Find("Catalogue").transform.position;
        spawnPosition.y -= yComponent;
        spawnPosition.z -= 0.35f;

        i = 0;
        //Debug.Log (spawnObjects[0].name);
        foreach (GameObject spawnObject in spawnObjects)

            refObjects[i] = ((GameObject)Instantiate(spawnObject, spawnPosition, Quaternion.identity));

            refObjects[i].GetComponent<Rigidbody>().isKinematic = true;
            Collider[] colliders = refObjects[i].GetComponentsInChildren<Collider>();

            /// to make the spawned gameobj, face the user..
            Quaternion toQuat = Camera.main.transform.localRotation;
            toQuat.x = 0;
            toQuat.z = 0;
            refObjects[i].transform.rotation = toQuat;

            i = i + 1;

the receiver is not at all able to automatically spawn the game object ......

Can any one help me with this ..Thnx :smile:

PS: sorry for the improper editing of code :persevere:


Best Answer


  • Hi,

    I'm trying to add a button in my HoloLens app which would send a message to my Desktop/PC app to launch an application on my Desktop. Could you please briefly explain what are the steps to be followed in order to achieve this using CustomMessages.


  • Thank you both so much! You helped me unbelievably much!

Sign In or Register to comment.