Search Unity

Spectator View Setup - No NetworkDiscoveryWithAnchor objects

Discussion in 'VR' started by GregPD65356T, Apr 9, 2018.

  1. GregPD65356T

    GregPD65356T

    Joined:
    Apr 9, 2018
    Posts:
    15
    This is the same question as this one, but worded differently to avoid spamming.

    I am setting up Spectator View for a project that's under an NDA. This is my first time doing this, and I'm already running into some trouble regarding anchors.

    I followed the steps explained in this blog, but one of the errors I got is the following:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object SpectatorView.JoinSelectedSessionButton.Update () (at Assets/Addons/HolographicCameraRig/SV_UNET/Prefabs/Support/Scripts/UI/JoinSelectedSessionButton.cs:32)
    where line 32 of JoinSelectedSessionButton.cs is
    if (networkDiscovery.running && networkDiscovery.isClient)

    The static variable
    Instance 
    of the NetworkDiscoveryWithAnchors class is null, as the starting code for that class did not find any objects that are of type NetworkDiscoveryWithAnchors. That instance is assigned to
    networkDiscovery
    . This debug output explains:

    Code (CSharp):
    1. Expected exactly 1 SpectatorView.NetworkDiscoveryWithAnchors but found 0 UnityEngine.Debug:LogFormat(String, Object[]) SpectatorView.NetworkDiscoveryWithAnchors:get_Instance() (at Assets/Addons/HolographicCameraRig/SV_UNET/Scripts/NetworkDiscoveryWithAnchors.cs:33) SpectatorView.SpectatorViewManager:Update() (at Assets/Addons/HolographicCameraRig/Scripts/SpectatorViewManager.cs:298)
    I don't have any anchors in my scene at the moment. Before I add an anchor into the scene, though, I want to make sure that when I do so, this line
    Code (CSharp):
    1. NetworkDiscoveryWithAnchors[] objects = FindObjectsOfType<NetworkDiscoveryWithAnchors>();
    will return an array of length one.

    I tried setting the hologram I want to anchor to as a child of a game object with the NetworkDiscoveryWithAnchors script. That didn't work. I also tried making the hologram as a child of the UNetAnchorRoot game object that's part of the Sharing prefab. That didn't work as well.

    What am I supposed to do? I feel like I don't need to do anything except add exactly one anchor to the scene (which I don't know how quite yet).
     
  2. Din0m1te

    Din0m1te

    Joined:
    Sep 9, 2015
    Posts:
    34
    NetworkDiscoveryWithAnchors has nothing do to with anchors (despite the name). It's a component you need to attach to any GameObject in your scene. And there should be exactly one GameObject with this component on it. I suggest you put it on the UNetAnchorManager GameObject.

    NetworkDiscoveryWithAnchors will discovery UNET sessions you can join to. The anchoring is done by the UNetAnchorManager component.
     
  3. Din0m1te

    Din0m1te

    Joined:
    Sep 9, 2015
    Posts:
    34
  4. GregPD65356T

    GregPD65356T

    Joined:
    Apr 9, 2018
    Posts:
    15
    Hang on; does the version of the Unity editor where the NDA project is built upon need to be the latest? We're using 2017.1.0f3. Here, in the example scene, it's opened on 2017.3.1f1.

    The Network Discovery with Anchors component is attached to the UNetSharingStage game object, which is part of the Sharing prefab that exists in the toolkit. I have that prefab already in my NDA project, with the exception that it's older than the latest in the GitHub repo.

    When I run the SharedHolograms sample scene, this time I don't see the errors as described above. The only errors I see are that the library for the Compositor Interface does not exist.
     
  5. GregPD65356T

    GregPD65356T

    Joined:
    Apr 9, 2018
    Posts:
    15
    Well, hang on. If that component is attached to that game object as part of a prefab, why is FindObjectsByType returning an array of size zero? It should be one.

    That's something that doesn't make any sense.
     
  6. Din0m1te

    Din0m1te

    Joined:
    Sep 9, 2015
    Posts:
    34
    If you drag the prefab into your scene and make sure there is no other GameObject with the Network Discovery on it, it should return an array of size one. That's right. If that is not the case, then something else is wrong. Try typing into the Hierarchy searchbox "t:NetworkDiscoveryWithAnchors" to find GameObject with the component on it.

    The errors about the missing compositor interface are fine. You have to build the required DLL files and put them into your plugins folder. The SV Documentation is helpful here.
     
  7. GregPD65356T

    GregPD65356T

    Joined:
    Apr 9, 2018
    Posts:
    15
    I already have the DLL files for the compositor interface in place. There's a bug in Unity 2017.1.0f3 where if the Compositor tab is sitting in the Additional Windows panel on startup, it tries to load up the contents of that pane first before the libraries.
     
  8. GregPD65356T

    GregPD65356T

    Joined:
    Apr 9, 2018
    Posts:
    15
    I think there's something else wrong. The Hierarchy searchbox with the string mentioned does not raise any game objects where it has a NetworkDiscoveryWithAnchors component. But through manual checking, since I don't have that many game objects, I have three game objects where each one has a NetworkDiscoveryWithAnchors component.

    I'm still getting the same errors as above, where instead of the debug saying there's three objects with that component, it's still saying zero. That's really strange.

    Can it be the sequence where the objects are instantiated? I don't understand why this is happening when FindObjectsOfType in the NetworkDiscoveryWithAnchors script is supposed to return all game objects that have this component.