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

Network.Connect Is Not Recognized

[c-sharp]

using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
using System.Net;
using System.IO;
using System.Collections.Generic;
using System;

public class SwitchCommander : MonoBehaviour
{
private bool switchOn = false;
Renderer rend;

private string url = "http://192.168.1.119";
private string urlON = "http://192.168.1.119/socket1On";
private string urlOFF = "http://192.168.1.119/socket1Off";

void Start()
{
rend = GetComponent();

decideColor();

}

// called when selected
void OnSelect()
{
switchOn = !switchOn;
if (switchOn)
{
Network.Connect(urlON,80);
}

else
{
    Network.Connect(urlOFF,80);
}
decideColor();

}

private void decideColor()
{
if (switchOn == false)
rend.material.color = Color.red;
else if (switchOn == true)
rend.material.color = Color.green;
}
}

Why is code not recognizing this reference for hololens?

Tagged:

Answers

  • Options

    What is the error you are seeing. Are you seeing it if you open the script in Visual Studio, or just in Unity. Any additional info you can provide will help us figure out what is going on.

  • Options

    It looks like you are trying to use the older version of Unity Networking. This version likely didn't have support for Windows Store (UWP) apps.

    Check out the documentation for the new networking for Unity. I've not tried it myself, but I know people who have had it working recently.

    ===
    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?)

  • Options

    It builds in visual studio, building it with the hololens emulator says the network does not exist in the context. The references have been added already.

  • Options

    When developing for Windows Store apps (as all HoloLens app are), Unity makes two Visual Studio solutions. One is in the context of the Editor (which is not a Windows Store app) and the other is in the context of the Windows Store app.

    If you double click a script in unity, unity will open the version of the script in the editor context. I believe that this is the Visual Studio that is building for you.

    When you 'build' from Unity to export the project for deploying to HoloLens, the Windows Store version of the solution is generated in the folder you target. It's this solution that you would deploy to the emulator. In this case I would expect you to get compiler errors trying to use Network.Connect. Unity doesn't export the now deprecated Network functionality to Windows Store apps. You need to use their newer network libraries. I think NetworkManager is the new name of the entry class for Unity Networking.

    ===
    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?)

  • Options

    Is there any example code using NetworkManager for hololens development, cannot seem to get this to work.

  • Options

    Me too facing the same error.. Please help how to get rid of this

Sign In or Register to comment.