0
\$\begingroup\$

I am having issues with black screen when running the emulation mode or simulator for Microsoft hololens. In the preview the camera shows what the user should see. I see no obvious reason to behave like this and no error/warning is given. I am using code snippets from the Origami tutorial,except I chose to use RayCastNonAlloc.

Preview Game viev
Movement.cs
public class Movement : MonoBehaviour {
public GameObject person; public float seconds;
private Vector3 point = new Vector3(0,0,0); private RaycastHit[] rayHit = new RaycastHit[5];

void OnSelect()
{
    person.transform.position = Vector3.Lerp(person.transform.position, point, seconds * Time.deltaTime);
}


// Update is called once per frame
void Update()
{
    if (Physics.RaycastNonAlloc(Camera.main.transform.position, Camera.main.transform.forward, rayHit, Mathf.Infinity, ~0) > 0)
    {

        foreach (RaycastHit hit in rayHit)
        {

            point.x = Mathf.Clamp(hit.point.x, -290f, 6970f);
            point.y = Mathf.Clamp(hit.point.y, -40f, 1860f);
            point.z = Mathf.Clamp(hit.point.z, -1700f, 140f);
        }
    }

}
}`


Scene.cs
using UnityEngine; using UnityEngine.XR.WSA.Input; public class Scene : MonoBehaviour

{

public GameObject cursor;
public GameObject Focused { get; private set; }
public Scene Instance { get; private set; }


private GestureRecognizer recognizer;
private MeshRenderer Renderer;
private readonly RaycastHit[] rayHit = new RaycastHit[5];


void Awake()
{
    Instance = this;
    recognizer = new GestureRecognizer();
    recognizer.Tapped += (args) =>
    {
        if (Focused != null)
        {
            Focused.SendMessageUpwards("OnSelect", SendMessageOptions.DontRequireReceiver);
        }


    };
    recognizer.StartCapturingGestures();
    Renderer = cursor.GetComponent<MeshRenderer>();
}


void Update()
{
    GameObject oldFocused = Focused;

    if (Physics.RaycastNonAlloc(Camera.main.transform.position,Camera.main.transform.forward,rayHit,Mathf.Infinity,~0)>0)
    {
        Renderer.enabled = true;
        foreach ( RaycastHit hit in rayHit)
        {

            cursor.transform.position = hit.point;
            cursor.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
            Focused = hit.collider.gameObject;
        }
    }

    else
    {
        Focused = null;
        Renderer.enabled = false;
    }
    if (Focused != oldFocused)
    {
        recognizer.CancelGestures();
        recognizer.StartCapturingGestures();
    }
}

}

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Your camera has 0 fov in the second image which is why it isn't rendering anything.

You may not have the project set up properly to use XR for the Hololens/Windows Mixed Reality as Unity sets the fov automatically for the device. (Source) Try checking that.

I suggest also to use either the Holotoolkit or the MixedRealityToolkit from the Github page. (Both exist in the Releases)

You can also follow the setup without the Toolkit on the MSDN page.

\$\endgroup\$
1
  • \$\begingroup\$ I checked the sites your provided, and I have all the things up to date. All properties of the camera are looking good during Edit mode, while player mode overrides all values which cannot be edited during Play mode. \$\endgroup\$
    – shanji97
    Commented Jan 24, 2019 at 13:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .