コード例 #1
0
    // ShowGeometry
    public void ShowGeometry(bool show)
    {
        // Load up the prefab
        if (GeometryReference == null)
        {
            GeometryReference =
                GameObject.Instantiate(Resources.Load("OVRMagReference")) as GameObject;
            GeometryReferenceMarkMat = GeometryReference.transform.Find("Mark").renderer.material;
        }

        if (GeometryReference != null)
        {
            GeometryReference.SetActive(show);
            AttachGeometryToCamera(show, ref GeometryReference);
            OVRUtils.SetLocalTransformIdentity(ref GeometryReference);
        }

        // Load up the prefab
        if (GeometryCompass == null)
        {
            GeometryCompass =
                GameObject.Instantiate(Resources.Load("OVRMagCompass")) as GameObject;
        }

        if (GeometryCompass != null)
        {
            GeometryCompass.SetActive(show);
            AttachGeometryToCamera(show, ref GeometryCompass);
            OVRUtils.SetLocalTransformIdentity(ref GeometryCompass);
        }
    }
コード例 #2
0
 /// <summary>
 /// Attachs the geometry to camera.
 /// </summary>
 /// <param name="attach">If set to <c>true</c> attach.</param>
 /// <param name="go">Go.</param>
 public void AttachGeometryToCamera(bool attach, ref GameObject go)
 {
     if (CameraController != null)
     {
         if (attach == true)
         {
             CameraController.AttachGameObjectToCamera(ref go);
             OVRUtils.SetLocalTransformIdentity(ref go);
             Vector3 lp = go.transform.localPosition;
             // we will move the position of everything over to the left, so get
             // IPD / 2 and position camera towards negative X
             float ipd = 0.0f;
             CameraController.GetIPD(ref ipd);
             lp.x -= ipd * 0.5f;
             go.transform.localPosition = lp;
         }
     }
 }